1、防止不支持js的瀏覽器出問題可以這樣處理JS代碼 <script type="text/javascript"> <!-- document.write("Hello World!"); //--> </script> 2、JS放置位置: header:確保腳本被調(diào)用時已經(jīng)加載 body:頁面載入時就調(diào)用 外部js文件:不包含<script>標(biāo)簽 用法:<script src = "xxx.js">.....</sceipt> 3、注釋 單行:// 多行:/*.....*/ 4、=== 全等符號 表示類型和值都相等 5、三種提示框 警告:alert("alert"); 確認(rèn):confirm("confirm"); 提示:prompt("prompt","默認(rèn)值"); 6、for in 聲明 for (變量 in 對象) { 在此執(zhí)行代碼 } 7、正則表達(dá)式 test()方法:檢索字符串中的指定值,如果有返回True,否則False var patt1=new RegExp("e"); document.write(patt1.test("The best things in life are free")); exec()方法:檢索字符中中的指定值,如果有返回找到的值,否則返回null var patt1=new RegExp("e"); document.write(patt1.exec("The best things in life are free")); compile()方法:用于改變檢索模式和添加刪除第二個參數(shù)