1. 程式人生 > 實用技巧 >JavaScript-Runoob-Browser-Window:Window top 屬性

JavaScript-Runoob-Browser-Window:Window top 屬性

ylbtech-JavaScript-Runoob-Browser-Window:Window top 屬性

1.返回頂部
1、

Windowtop屬性

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>
嘗試一下 » 2、
2.返回頂部
3.返回頂部
4.返回頂部
5.返回頂部
1、 https://www.runoob.com/jsref/prop-win-top.html 2、
6.返回頂部
作者:ylbtech
出處:http://ylbtech.cnblogs.com/
本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段宣告,且在文章頁面明顯位置給出原文連線,否則保留追究法律責任的權利。