国产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對象的所有屬性
/*
    for(name|index in obj|arr){
        
    }
    描述:只能循環(huán)數(shù)組的下標,或對象的屬性。
    說明:如果循環(huán)數(shù)組的話,每次循將取下標值。
          對于數(shù)組中值為undefined的,不會循環(huán)。
          循環(huán)數(shù)組,只返回有效的值。
        
          如果循對象的話,每次循環(huán)取對象屬性。
          嚴格的來說,對象中沒有方法一說,所有的都是屬性。
          將一個函數(shù)賦給一個屬性后,這個屬性就變成方法了。
*/
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>
    //實例:測試當前網(wǎng)頁的寬度和高度
    //兼容所有瀏覽器
    var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
    var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
    //輸出結果
    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("你確認要刪除嗎?")){
                //跳轉到指定刪除頁面執(zhí)行刪除操作
               location.href="http://m.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對象的所有屬性 /* for(name|index in obj|arr){ } 描述:只能循環(huán)數(shù)組的下標,或對象的屬性。 說明:如果循環(huán)數(shù)組的話,每次循將取下標值。 對于數(shù)組中值為undefined的,不會循環(huán)。 循環(huán)數(shù)組,只返回有效的值。 如果循對象的話,每次循環(huán)取對象屬性。 嚴格的來說,對象中沒有方法一說,所有的都是屬性。 將一個函數(shù)賦給一個屬性后,這個屬性就變成方法了。 */ var i = 1; for(var name in window) { document.write(i+" "+name+"<br>"); i++; } </script> </head> <body> </body> </html>
submitReset Code