小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

常用的 Javascript 操作匯總 (二)

 WindySky 2009-06-24

17 定義函數(shù)

1: <script language=”JavaScript”>
2: <!--
3: function multiple(number1,number2) {
4: var result = number1 * number2;
5: return result;
6: }

7: // -->
8: </script>



18 調(diào)用JS函數(shù)

1: <a href=”#” onClick=”functionName()”>Link text</a>
2: <a href="/”javascript:functionName"()”>Link text</a>



19 在頁(yè)面加載完成后執(zhí)行函數(shù)

1: <body onLoad=”functionName();”>
2: Body of the page
3: </body>


20 條件判斷

1: <script>
2: <!--
3: var userChoice = window.confirm(“Choose OK or Cancel”);
4: var result = (userChoice == true) ? “OK” : “Cancel”;
5: document.write(result);
6: // -->
7: </script>



21 指定次數(shù)循環(huán)

1: <script>
2: <!--
3: var myArray = new Array(3);
4: myArray[0] = “Item 0”;
5: myArray[1] = “Item 1”;
6: myArray[2] = “Item 2”;
7: for (i = 0; i < myArray.length; i++) {
8: document.write(myArray +<br>”);
9: }

10: // -->
11: </script>



22 設(shè)定將來(lái)執(zhí)行

1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: }

6: window.setTimeout(“hello()”,5000);
7: // -->
8: </script>



23 定時(shí)執(zhí)行函數(shù)

1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: window.setTimeout(“hello()”,5000);
6: }

7: window.setTimeout(“hello()”,5000);
8: // -->
9: </script>



24 取消定時(shí)執(zhí)行

1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: }

6: var myTimeout = window.setTimeout(“hello()”,5000);
7: window.clearTimeout(myTimeout);
8: // -->
9: </script>

25 在頁(yè)面卸載時(shí)候執(zhí)行函數(shù)

1: <body onUnload=”functionName();”>
2: Body of the page
3: </body>

JavaScript就這么回事2:瀏覽器輸出


26 訪問(wèn)document對(duì)象

1: <script language=”JavaScript”>
2: var myURL = document.URL;
3: window.alert(myURL);
4: </script>



27 動(dòng)態(tài)輸出HTML

1: <script language=”JavaScript”>
2: document.write(“<p>Here’s some information about this document:</p>”);
3: document.write(“<ul>”);
4: document.write(“<li>Referring Document: “ + document.referrer +</li>”);
5: document.write(“<li>Domain: “ + document.domain +</li>”);
6: document.write(“<li>URL: “ + document.URL +</li>”);
7: document.write(“</ul>”);
8: </script>


28 輸出換行

1: document.writeln(“<strong>a</strong>”);
2: document.writeln(“b”);

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多