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 »

Description

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:

The parent Property


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 Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.