Window top 属性

定义和用法

top 属性返回当前浏览器窗口中最顶层的窗口。

top 属性是只读的。

提示

top 属性与 parent 属性不同。

window.top 返回窗口层次结构中最顶层的窗口。

window.parent 返回窗口的直接父级。

另请参阅:

parent 属性

实例

这个窗口是最上面的窗口吗:

if (window.top != window.self) {
  text = "This window is NOT the topmost window!";
} else {
  text = "This window is the topmost window!";
}

亲自试一试

Cú pháp

window.top

Giá trị trả về

Loại Mô tả
Đối tượng. Cửa sổ trên cùng trong cấu trúc层次 cửa sổ của trình duyệt hiện tại.

Hỗ trợ trình duyệt

Tất cả các trình duyệt đều hỗ trợ window.top

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Hỗ trợ Hỗ trợ Hỗ trợ Hỗ trợ Hỗ trợ Hỗ trợ