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

window object properties and methods

Window object properties

First, loop through all the properties of the window object:

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

<body>
</body>
</html>
  • name : Refers to the name of the browser window or frame. This name is used for the target attribute of the a tag.

  • Set the name of the window: window.name = “newWin”

  • Get the name of the window: document.write (name);

  • top: Represents the top-level window. For example: window.top

  • parent: represents the parent window, mainly used for frames.

  • self: represents the current window, mainly used in frames.

  • innerWidth: refers to the inner width of the browser window (excluding menu bar, toolbar, address bar, status bar). This attribute is supported by Firefox.

  • Under IE, use document.documentElement.clientWidth instead of window.innerWidth

  • innerHeight: refers to the inner height of the browser window (excluding menu bar, toolbar, address bar, status bar). This attribute is supported by Firefox.

  • Under IE, use document.documentElement.clientHeight instead of window.innerHeight

  • ##document.documentElement is< ;html> mark object

  • document.body is <body> mark object

  • <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>php.cn</title>
    <script>
    //實(shí)例:測(cè)試當(dāng)前網(wǎng)頁(yè)的寬度和高度
    //兼容所有瀏覽器
    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 object method

  • alert(): Pops up a warning dialog box.

  • prompt(): Pops up an input dialog box.

  • confirm(): Pops up a confirmation dialog box. Returns true if the OK button is clicked and false if Cancel is clicked.

  • close(): Close the window

  • print(): Print the window

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