Web Hosting Offers
See the new scripts recently added to Dynamic Drive. Click here.
Original, practical CSS codes and examples such as CSS menus for your site.
    Search code samples  
 
  Keyword
 
 
 
   
 
 
  Code Samples
 
ASP
CSS
Dhtml
Html
Javascript
PHP
 
   
     LOGIN HERE  
 
Username
Password
Forgot Password
Verify Signup
 
 
 

Javascript >> Frames

How do I access a variable within one nested frameset from another?

Visitor Ratings (0) :

Description
If, for example, the following frameset was defined:

<frameset rows="50%,50%">
<frameset cols="50%,50%">
<frame name="frame1A" src="frame1A.html">
<frame name="frame1B" src="frame1B.html">
</frameset>
<frameset cols="50%,50%">
<frame name="frame2A" src="frame2A.html">
<frame name="frame2B" src="frame2B.html">
</frameset>
</frameset>

To access a variable within frame1A from frame1B:

var variableName = parent.frame1A.variableName;

To access a variable within frame1A from frame2B:

var variableName = parent.frame1A.variableName;

It does not matter, that there are two nested framesets. The frames in this example are all at the level below the parent.

If, for example, the following frameset was defined:

<frameset rows="50%,50%">
<frameset cols="50%,50%">
<frame name="frame1A" src="frame1A.html">
<frame name="frame1B" src="frame1B.html">
</frameset>
<frame name="frame2" src="frame2.html">
</frameset>

And if the contents of frame2.html contained:

<frameset cols="50%,50%">
<frame name="frame2A" src="frame2A.html">
<frame name="frame2B" src="frame2B.html">
</frameset>

To access a variable within frame1A from frame1B:

var variableName = parent.frame1A.variableName;

To access a variable within frame1A from frame2B:

var variableName = parent.parent.frame1A.variableName;
Code
Select All
 Rate this Resource