久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

常用的 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 在頁面加載完成后執(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è)定將來執(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 在頁面卸載時(shí)候執(zhí)行函數(shù)

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

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


26 訪問document對象

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



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

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多