English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Window top Property

JavaScript Window Object

topA read-only property that returns a reference to the topmost window in the window hierarchy.

In whichwindow.parentThe property returns the direct parent of the current window, while window.top returns the topmost window in the window object hierarchy.

This property is particularly useful when you are handling a window in a child frame of one or more parent frames and want to access the topmost frame set.

Syntax:

window.top
if (window.top == window.self) {
   // This window is the topmost window
}
Test and See‹/›

Browser Compatibility

All browsers fully support the top property:

Property
topYesYesYesYesYes

Technical Details

Return Value:Reference to the topmost window in the window hierarchy

Related References

Window (Window) Reference:window.parent property

Window (Window) Reference:window.self property

JavaScript Window Object