[ Team LiB ] Previous Section Next Section

7.4 Replacing a Frameset with a Single Page

NN 2, IE 3

7.4.1 Problem

You want a script statement in one frame to replace the frameset with a new document, such as removing your frameset to make way for an entirely different web site.

7.4.2 Solution

Assign the URL to the topmost parent of the frame hierarchy:


This is the scripted equivalent of the following hyperlink specification:

<a href="newPage.html" target="_top">...</a>

Use the scripted version only if you are performing some other script activity leading up to the replacement, or you need your page to validate to the XHTML strict DTD, which forbids the target attribute.

7.4.3 Discussion

You could reference the parent frameset instead of the top in a simple frameset. In this instance, a reference to the top and parent framesets points to the same object. But if you specify the topmost frameset, you are guaranteed removal of any vestiges of earlier framesets, especially if the script is potentially running within a nested frameset. That includes a frameset from an origin other than your own domain and server.

7.4.4 See Also

Recipe 7.5 for how to use this technique to prevent your site from being displayed in another site's frameset.

    [ Team LiB ] Previous Section Next Section