1:基礎(chǔ)知識
<script language=”JavaScript”>
JavaScript code goes here
</script>

1: <script language=”JavaScript”>
2: <!--
3: document.write(“Hello”);
4: // -->
5: </script>
1: <noscript>
2: Hello to the non-JavaScript browser.
3: </noscript>
1: <script language=”JavaScript” src="/”filename.js"”></script>
1: // This is a comment
2: document.write(“Hello”); // This is a comment
3: /*
4: All of this
5: is a comment
6: */
1: document.write(“<strong>Hello</strong>”);
1: var myVariable = “some value”;
1: var myString = “String1” + “String2”;
1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “Hello there”;
4: var therePlace = myVariable.search(“there”);
5: document.write(therePlace);
6: // -->
7: </script>
1: thisVar.replace(“Monday”,”Friday”);
1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “a,b,c,d”;
4: var stringArray = myVariable.split(“,”);
5: document.write(stringArray[0]);
6: document.write(stringArray[1]);
7: document.write(stringArray[2]);
8: document.write(stringArray[3]);
9: // -->
10: </script>
1: <script language=”JavaScript”>
2: <!--
3: window.alert(“Hello”);
4: // -->
5: </script>
1: <script language=”JavaScript”>
2: <!--
3: var result = window.confirm(“Click OK to continue”);
4: // -->
5: </script>
1: <script language=”JavaScript”>
2: <!--
3: function multiple(number1,number2) {
4: var result = number1 * number2;
5: return result;
6: }
7: // -->
8: </script>
1: <a href=”#” onClick=”functionName()”>Link text</a>
2: <a href="/”javascript:functionName"()”>Link text</a>
1: <body onLoad=”functionName();”>
2: Body of the page
3: </body>
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>
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[i] + “<br/>”);
9: }
10: // -->
11: </script>
1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: }
6: window.setTimeout(“hello()”,5000);
7: // -->
8: </script>
1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: window.setTimeout(“hello()”,5000);
6: }
7: window.setTimeout(“hello()”,5000);
8: // -->
9: </script>
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>
1: <body onUnload=”functionName();”>
2: Body of the page
3: </body>
ExtJS教程- Hibernate教程-Struts2 教程-Lucene教程
1 創(chuàng)建腳本塊





2 隱藏腳本代碼





在不支持JavaScript的瀏覽器中將不執(zhí)行相關(guān)代碼
3 瀏覽器不支持的時(shí)候顯示



4 鏈接外部腳本文件

5 注釋腳本






6 輸出到瀏覽器

7 定義變量

8 字符串相加

9 字符串搜索







10 字符串替換

11 格式化字串
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 12 創(chuàng)建數(shù)組 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 13 數(shù)組排序 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
14 分割字符串










15 彈出警告信息





16 彈出確認(rèn)框





17 定義函數(shù)








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


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



20 條件判斷







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











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








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









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









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



ExtJS教程- Hibernate教程-Struts2 教程-Lucene教程