JavaScript-Runoob-Browser-Window:Window top 屬性
阿新 • • 發佈:2020-07-22
ylbtech-JavaScript-Runoob-Browser-Window:Window top 屬性 |
1.返回頂部 |
Windowtop屬性
Window 物件定義和用法
Top屬性返回當前視窗的最頂層瀏覽器視窗。
語法
window.top瀏覽器支援
所有主要瀏覽器都支援 top 屬性
例項
例項
當點選"Check window"按鈕,check()被呼叫,並檢查當前視窗的狀態:
<!DOCTYPE html> <html> <head> <meta charset="utf-8">嘗試一下 » 2、<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.返回頂部 |
3.返回頂部 |
4.返回頂部 |
5.返回頂部 |
6.返回頂部 |
作者:ylbtech 出處:http://ylbtech.cnblogs.com/ 本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段宣告,且在文章頁面明顯位置給出原文連線,否則保留追究法律責任的權利。 |