Page 1 of 1

sharing script /w other frames

Posted: Mon Nov 25, 2002 5:43 am
by Kyori
I need to write new HTML on a frame. However everytime document.write is called from frame, the whole page reloads (not just that frame).

BTW, index.htm is just composed of text.

main.htm

Code: Select all

<script>
function d()
{
document.write("hello");
}
</script>


<frameset rows="80%,*" framespacing=0 border=0 frameborder=0>
 <frameset cols="30%,*" framespacing=0 border=0 frameborder=0>
    <frame src="index.htm" name="stat" noresize>
    <frameset rows="40%,*" framespacing=0 border=0 frameborder=0>
      <frame src="index.htm" name="action" noresize> 
      <frame src="map.php" name="map" noresize>
    </frameset>
 </frameset>
 <frame src="index.htm" name="mesg" noresize>
</frameset>

snip from map.php

Code: Select all

echo "
<script>
parent.d();
</script>";

Also, how can I use variables from main.htm in the "action" frame?

thanks

Posted: Mon Nov 25, 2002 11:13 pm
by volka
hm hm hm...only guessing but you might pass a reference to the frame's document to the function.

Code: Select all

<script>
function d(oDoc)
&#123;
   oDoc.write("hello");
&#125;
</script>
---------------
<script>
parent.d(document); 
</script>