|
<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”);
JavaScript技術:JavaScript基本入門語法集合第1/3頁,轉載需保留來源!
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。