亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JavaScript兩個常用的客戶端輸出方法

常用的兩個客戶端輸出方法


document.write(str)

  • 描述:在網(wǎng)頁的<body>標記,輸出str的內(nèi)容。

  • document意思“文檔”,就是整個網(wǎng)頁了。

  • document是一個文檔對象,代表整個網(wǎng)頁。

  •  write()是document對象的一個輸出方法。

  • “.”小數(shù)點:通過小數(shù)點(.)來調(diào)用對象的方法。

  • str:表示要輸出的內(nèi)容。

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script type="text/javascript">
            //在<body>中輸出一句話
            document.write("歡迎來到php.cn");
        </script>
    </head>
    <body>
    </body>
</html>


window.alert(str)

  • 描述:在當前窗口中彈出一個警告對話框,str為對話框中顯示的內(nèi)容。

  • window代表當前瀏覽器窗口,window是一個窗口對象。

  • alert()方法:彈出一個對話框。

  • str:表示要輸出的內(nèi)容。

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script type="text/javascript">
            //打開網(wǎng)頁時,彈出一個對話框
            window.alert("歡迎來到php.cn");
        </script>
    </head>
    <body>
    </body>
</html>


Weiter lernen
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> //在<body>中輸出一句話 document.write("歡迎來到php.cn"); </script> </head> <body> </body> </html>
einreichenCode zurücksetzen