<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 147  文章 - 71  trackbacks - 0
    <2009年1月>
    28293031123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿(1)

    隨筆分類(146)

    隨筆檔案(147)

    文章分類(28)

    文章檔案(28)

    喜歡的Blog

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    創建腳本塊

    1<script language=”JavaScript”> 
    2JavaScript code goes here 
    3
    </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 */

    輸出到瀏覽器
    1document.write(“<strong>Hello</strong>”); 

    定義變量
    1var myVariable = “some value”;

    字符串相加
    1var myString = “String1” + “String2”; 

    字符串搜索
    1<script language=”JavaScript”> 
    2 var myVariable = “Hello there”; 
    3 var therePlace = myVariable.search(“there”); 
    4 document.write(therePlace); 
    5
    </script>

    字符串替換
    1<script language=”JavaScript”> 
    2 thisVar.replace(“Monday”,”Friday”);
    3
    </script>

    格式化字串
     1<script language=”JavaScript”> 
     2  var myVariable = “Hello there”; 
     3  document.write(myVariable.big() + “<br>”); 
     4  document.write(myVariable.blink() + “<br>”); 
     5  document.write(myVariable.bold() + “<br>”); 
     6  document.write(myVariable.fixed() + “<br>”); 
     7  document.write(myVariable.fontcolor(“red”) + “<br>”); 
     8  document.write(myVariable.fontsize(“18pt”) + “<br>”); 
     9  document.write(myVariable.italics() + “<br>”); 
    10  document.write(myVariable.small() + “<br>”); 
    11  document.write(myVariable.strike() + “<br>”); 
    12  document.write(myVariable.sub() + “<br>”); 
    13  document.write(myVariable.sup() + “<br>”); 
    14  document.write(myVariable.toLowerCase() + “<br>”); 
    15  document.write(myVariable.toUpperCase() + “<br>”);   
    16  var firstString = “My String”; 
    17  var finalString = firstString.bold().toLowerCase().fontcolor(“red”); 
    18
    </script>

    創建數組
    1<script language=”JavaScript”> 
    2 var myArray = new Array(5); 
    3 myArray[0= “First Entry”; 
    4 myArray[1= “Second Entry”; 
    5 myArray[2= “Third Entry”; 
    6 myArray[3= “Fourth Entry”; 
    7 myArray[4= “Fifth Entry”; 
    8 var anotherArray = new Array(“First Entry”,”Second Entry”,”Third Entry”,”Fourth Entry”,”Fifth Entry”); 
    9
    </script>

    數組排序
    1<script language=”JavaScript”> 
    2 var myArray = new Array(5); 
    3 myArray[0= “z”; 
    4 myArray[1= “c”; 
    5 myArray[2= “d”; 
    6 myArray[3= “a”; 
    7 myArray[4= “q”; 
    8 document.write(myArray.sort()); 
    9
    </script>

    分割字符串
    1<script language=”JavaScript”> 
    2 var myVariable = “a,b,c,d”; 
    3 var stringArray = myVariable.split(“,”); 
    4 document.write(stringArray[0]); 
    5 document.write(stringArray[1]); 
    6 document.write(stringArray[2]); 
    7 document.write(stringArray[3]); 
    8
    </script>

    彈出警告信息
    1<script language=”JavaScript”> 
    2 window.alert(“Hello”); 
    3
    </script>

    彈出確認框
    1<script language=”JavaScript”> 
    2 var result = window.confirm(“Click OK to continue”); 
    3
    </script>

    定義函數
    1<script language=”JavaScript”> 
    2 function multiple(number1,number2) {  
    3 var result = number1 * number2; 
    4 return result; 
    5 }
     
    6
    </script>

    調用JS函數
    1<href=”#” onClick=”functionName()”>Link text</a>
    2<href="/”javascript:functionName"()”>Link text</a>

    在頁面加載完成后執行函數
    1<body onLoad=”functionName();”>
    2Body of the page 
    3</body>

    條件判斷
    1<script> 
    2 var userChoice = window.confirm(“Choose OK or Cancel”); 
    3 var result = (userChoice == true? “OK” : “Cancel”; 
    4 document.write(result); 
    5
    </script>

    指定次數循環
    1<script> 
    2 var myArray = new Array(3); 
    3 myArray[0= “Item 0”; 
    4 myArray[1= “Item 1”; 
    5 myArray[2= “Item 2”; 
    6 for (i = 0; i < myArray.length; i++{  
    7 document.write(myArray[i] + “<br>”); 
    8 }
     
    9
    </script>

    設定將來執行
    1<script> 
    2 function hello() {  
    3 window.alert(“Hello”); 
    4 }
     
    5 window.setTimeout(“hello()”,5000); 
    6
    </script>

    定時執行函數
    1<script> 
    2 function hello() {  
    3 window.alert(“Hello”); 
    4 window.setTimeout(“hello()”,5000); 
    5 }
     
    6 window.setTimeout(“hello()”,5000); 
    7
    </script>

    取消定時執行
    1<script> 
    2 function hello() {  
    3 window.alert(“Hello”); 
    4 }
     
    5 var myTimeout = window.setTimeout(“hello()”,5000); 
    6 window.clearTimeout(myTimeout); 
    7
    </script>

    在頁面卸載時候執行函數
    1<body onUnload=”functionName();”> 
    2 Body of the page 
    3</body>
    posted on 2009-01-11 10:21 飛翔天使 閱讀(252) 評論(0)  編輯  收藏 所屬分類: javascript
    主站蜘蛛池模板: 国产精品久久久亚洲| 亚洲综合一区二区| 免费人成黄页在线观看日本| 亚洲影院在线观看| 性感美女视频在线观看免费精品| 一区二区免费在线观看| 亚洲精品福利在线观看| 亚洲国产精品成人AV无码久久综合影院| 日本免费在线观看| 亚洲变态另类一区二区三区| 久久亚洲精品视频| 影音先锋在线免费观看| 黄色免费在线网站| 国产亚洲情侣久久精品| 亚洲老熟女@TubeumTV| 亚洲国产一成久久精品国产成人综合| 最近2019年免费中文字幕高清 | 成年人免费网站在线观看| 农村寡妇一级毛片免费看视频 | 在线免费观看h片| 亚洲色欲啪啪久久WWW综合网| 亚洲精品国精品久久99热一| 暖暖在线日本免费中文| 免费无码毛片一区二区APP| 老妇激情毛片免费| 亚洲另类古典武侠| 亚洲精品乱码久久久久久按摩| 麻豆国产人免费人成免费视频| 久久午夜伦鲁片免费无码| 一级毛片在播放免费| 亚洲日韩精品无码专区加勒比☆ | 久久亚洲私人国产精品vA| 亚洲一本大道无码av天堂| 毛片免费在线播放| 啦啦啦完整版免费视频在线观看| 中国一级特黄高清免费的大片中国一级黄色片 | 中文字幕不卡免费高清视频| 婷婷亚洲综合五月天小说在线| 亚洲一区二区三区在线| 亚洲黄色网站视频| 亚洲成熟xxxxx电影|