Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Frame | Q76 [ previous next ]

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

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;

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.