創建腳本塊
<script language=”JavaScript”>
JavaScript code goes here
</script>
隱藏腳本代碼
<script language=”JavaScript”>
<!--
document.write(“Hello”);
// -->
</script>
浏覽器不支持的時候顯示
<noscript>
Hello to the non-JavaScript browser.
</noscript>
鏈接外部腳本文件
<script language=”JavaScript” src="/”youname.js"”></script>
注釋腳本
// This is a comment
document.write(“Hello”); // This is a comment
/*
All of this
is a comment
*/
輸出到浏覽器
document.write(“<strong>輸出內容</strong>”);
定義變量
var myVariable = “some value”;
字符串相加
var myString = “String1” + “String2”;
字符串搜索
<script language=”JavaScript”>
<!--
var myVariable = “Hello there”;
var therePlace = myVariable.search(“there”);
document.write(therePlace);
// -->
</script>
字符串替換
thisVar.replace(“Monday”,”Friday”);
當前1/3頁
123下一頁閱讀全文