Window top Property
Example
Is this window the topmost window:
if (window.top != window.self) {
text = "This window is NOT the topmost window!";
} else {
text = "This window is the topmost window!";
}
Try it Yourself »
Definition and Usage
The top
property returns the topmost window in the current browser window.
The top
property is read-only.
Note
The top
property is not the same as the
parent
property.
window.top
returns the topmost window in the hierarchy of windows.
window.parent
returns the immediate parent of a window.
See Also:
Syntax
window.top
Return Value
Type | Description |
An object. | The topmost window in the hierarchy of windows in the current browser window. |
Browser Support
window.top
is supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |