The topmost window in a framed hierarchy.


JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
Property/method value type:Window object

The top property should consistently refer to the window at the top of the hierarchy. The window property refers to the current window.

You can test attributes of the top window against attributes of the current window to see if your script is running in a correctly framed context. This may be useful if you have a frame dependent page that may have been linked to by a search engine. You can force the page into the correct frame-set if you can detect that it has been invoked outside of it.

if(top != window)


// The window is in a frameset


This property will contain a meaningful value regardless of whether the window is in a frame or not.

If the pages are known to come from the same server, you may want to check the window.location.href property against the top.location.href property. However, this may cause problems if the pages come from different servers and cause the script to throw a security related exception.


See also:Frame object, Window object, Window.frame, Window.frames[], Window.parent, Window.window

Property attributes: