Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Frame | Q76 [ previous next ]

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;

©2018 Martin Webb