天天看點

Window top 屬性

Window top 屬性

Window 對象

Top屬性傳回目前視窗的最頂層浏覽器視窗。

window.top

Window top 屬性
Window top 屬性
Window top 屬性
Window top 屬性
Window top 屬性

所有主要浏覽器都支援 top 屬性

當點選"Check window"按鈕,check()被調用,并檢查目前視窗的狀态:

<!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" onclick="check()" value="檢查視窗">

</body>

</html>

Window top 屬性