国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

window物件屬性與方法

Window物件屬性

?首先,透過循環(huán)遍歷出window物件的所有屬性:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>php.cn</title>
<script>
//循環(huán)遍歷window對象的所有屬性
/*
    for(name|index in obj|arr){
        
    }
    描述:只能循環(huán)數(shù)組的下標(biāo),或?qū)ο蟮膶傩浴?    說明:如果循環(huán)數(shù)組的話,每次循將取下標(biāo)值。
          對于數(shù)組中值為undefined的,不會循環(huán)。
          循環(huán)數(shù)組,只返回有效的值。
        
          如果循對象的話,每次循環(huán)取對象屬性。
          嚴(yán)格的來說,對象中沒有方法一說,所有的都是屬性。
          將一個函數(shù)賦給一個屬性后,這個屬性就變成方法了。
*/
var i = 1;
for(var name in window)
{
    document.write(i+" "+name+"<br>");
    i++;
}
</script>
</head>

<body>
</body>
</html>
  • #name :指瀏覽器視窗的名字或框架的名字。這個名字是給a標(biāo)記的target屬性來用的。

  • 設(shè)定視窗的名稱:window.name = “newWin”

  • 取得視窗的名稱:document.write (name);

  • top:代表最頂層視窗。如:window.top

  • parent:代表父級窗口,主要用於框架。

  • self:代表目前窗口,主要用於框架中。

  • innerWidth:指瀏覽器視窗的內(nèi)寬(不含功能表列、工具列、網(wǎng)址列、狀態(tài)列),此屬性Firefox支援。

  • 在IE下,使用document.documentElement.clientWidth?來取代window.innerWidth

  • #innerHeight:指瀏覽器窗品的內(nèi)高(不含功能表列、工具列、網(wǎng)址列、狀態(tài)列),此屬性Firefox支援。

  • 在IE下,使用?document.documentElement.clientHeight?來取代?window.innerHeight

  • document.documentElement ??就是< ;html>標(biāo)記物件

  • document.body ?就是<body>標(biāo)記物件

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>php.cn</title>
<script>
//實(shí)例:測試當(dāng)前網(wǎng)頁的寬度和高度
//兼容所有瀏覽器
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
//輸出結(jié)果
document.write("寬度:"+width+",高度:"+height);
</script>
</head>
<body>
</body>
</html>

window物件方法

  • alert():彈出一個警告對話框。

  • prompt():彈出一個輸入對話框。

  • confirm():彈出一個確認(rèn)對話框。如果按一下「確定按鈕」返回true,如果按一下「取消」返回false。

  • close():關(guān)閉視窗

  • #print():列印視窗

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>php.cn</title>
<script>
    function delect() {
        if(window.confirm("你確認(rèn)要刪除嗎?")){
            //跳轉(zhuǎn)到指定刪除頁面執(zhí)行刪除操作
           location.href="http://miracleart.cn";   
        }     
    }
</script>
</head>
<body>
    <a href="#" onClick="delect()">刪除</a>
</body>
</html>
繼續(xù)學(xué)習(xí)
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>php.cn</title> <script> //循環(huán)遍歷window對象的所有屬性 /* for(name|index in obj|arr){ } 描述:只能循環(huán)數(shù)組的下標(biāo),或?qū)ο蟮膶傩浴? 說明:如果循環(huán)數(shù)組的話,每次循將取下標(biāo)值。 對于數(shù)組中值為undefined的,不會循環(huán)。 循環(huán)數(shù)組,只返回有效的值。 如果循對象的話,每次循環(huán)取對象屬性。 嚴(yán)格的來說,對象中沒有方法一說,所有的都是屬性。 將一個函數(shù)賦給一個屬性后,這個屬性就變成方法了。 */ var i = 1; for(var name in window) { document.write(i+" "+name+"<br>"); i++; } </script> </head> <body> </body> </html>
提交重置程式碼