July 29, 2000 - Sharing Functions between Frames
July 29, 2000 Sharing Functions between Frames Tips: July 2000
Yehuda Shiran, Ph.D.
|
upper
and lower
. Here is the frameset definition:
<HTML>
<HEAD>
<TITLE>Demonstrate Function Calls in Frames</TITLE>
</HEAD>
<FRAMESET ROWS="50, 50" FRAMEBORDER="yes" FRAMESPACING="1">
<FRAME SRC="000729c.html" NAME="upper" SCROLLING="no" MARGINHEIGHT="1" MARGINWIDTH="1">
<FRAME SRC="000729b.html" NAME="lower" SCROLLING="no" MARGINHEIGHT="1" MARGINWIDTH="1">
</FRAMESET>
</HTML>
The upper frame is defined in
000729c.html
:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function hello() {
alert("Hello from the Upper Frame");
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<H1>Upper Frame</H1>
</BODY>
</HTML>
And the lower frame is in 000729b.html
:
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>Lower Frame</H1>
<A HREF="javascript:top.upper.hello()">Call hello function from Upper Frame</A>
</BODY>
</HTML>
Notice how we reference hello()
from the upper frame: top.upper.hello()
. For more on frames, go to Column 37, JavaScript and Frames, Part II - The Famous Memory Game.