Window top 属性

约 460 字 更新于 2026-11-18 5iyo.com

Window top 属性

Window 对象

定义和用法

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

语法

window.top


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 top 属性


实例

实例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script>
function check(){
    if (window.top!=window.self) {
        document.write("<p>这个窗口不是最顶层窗口!我在一个框架?</p>")
    }
    else{
        document.write("<p>这个窗口是最顶层窗口!</p>")
    }
}
</script>
</head>
<body>
    
<input type="button" value="检查窗口">
    
</body>
</html>



Window 对象