Reference the top frame : frameset « HTML Tags « JavaScript Tutorial






index.html

<html>
    <head>
        <title>Frameset Example</title>
    </head>
    <frameset cols="100,*">
        <frame src="red.htm" name="redFrame" />
        <frame src="blue.htm" name="blueFrame" />
    </frameset>
</html>

red.htm

<head>
<title>redFrame</title>
</head>
<body>
    <h1>redFrame</h1>
    <table border="1">
        <tr>
            <td>window.name =</td><td><script>document.write(window.name)</script></td>
        </tr>
        <tr>
            <td>top.name =</td><td><script>document.write(top.name)</script></td>
        </tr>
        <tr>
            <td>parent.name =</td><td><script>document.write(parent.name)</script></td>
        </tr>
    </table>
</body>

blue.htm

<head>
<title>blueFrame</title>
</head>
<body>
    <h1>blueFrame</h1>
    <table border="1">
        <tr>
            <td>window.name =</td><td><script>document.write(window.name)</script></td>
        </tr>
        <tr>
            <td>top.name =</td><td><script>document.write(top.name)</script></td>
        </tr>
        <tr>
            <td>parent.name =</td><td><script>document.write(parent.name)</script></td>
        </tr>
    </table>
</body>








21.8.frameset
21.8.1.Output a frameset through document.write
21.8.2.Change frame location(URL)
21.8.3.Reference the top frame
21.8.4.Reference the parent frame
21.8.5.Nested framesets
21.8.6.Change two frames in a frame set
21.8.7.Reference element in frameset