sharing script /w other frames

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Kyori
Forum Newbie
Posts: 23
Joined: Mon Oct 14, 2002 5:23 am
Contact:

sharing script /w other frames

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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>
Post Reply