JavaScript基本入門語(yǔ)法集合第1/3頁(yè)
更新時(shí)間:2008年09月14日 21:13:22 作者:
對(duì)于新手來(lái)說(shuō),掌握下面的方法,基本上就可以自己些js了,入門必備
創(chuàng)建腳本塊
<script language=”JavaScript”>
JavaScript code goes here
</script>
隱藏腳本代碼
<script language=”JavaScript”>
<!--
document.write(“Hello”);
// -->
</script>
瀏覽器不支持的時(shí)候顯示
<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>輸出內(nèi)容</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”);
<script language=”JavaScript”>
JavaScript code goes here
</script>
隱藏腳本代碼
<script language=”JavaScript”>
<!--
document.write(“Hello”);
// -->
</script>
瀏覽器不支持的時(shí)候顯示
<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>輸出內(nèi)容</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”);
相關(guān)文章
深入學(xué)習(xí)JavaScript中的原型prototype
這篇文章主要介紹了深入學(xué)習(xí)JavaScript中的原型prototype,是JavaScript入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-08-08
JavaScript瀏覽器對(duì)象之一Window對(duì)象詳解
下面小編就為大家?guī)?lái)一篇JavaScript瀏覽器對(duì)象之一Window對(duì)象詳解。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-06-06
JavaScript數(shù)據(jù)結(jié)構(gòu)和算法之二叉樹(shù)詳解
這篇文章主要介紹了JavaScript數(shù)據(jù)結(jié)構(gòu)和算法之二叉樹(shù)詳解,本文講解了二叉樹(shù)的概念、二叉樹(shù)的特點(diǎn)、二叉樹(shù)節(jié)點(diǎn)的定義、查找最大和最小值等內(nèi)容,需要的朋友可以參考下2015-02-02
javascript中call()、apply()的區(qū)別
這篇文章主要介紹了javascript中call()、apply()的區(qū)別,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
js中top/parent/frame概述及案例應(yīng)用
top:永遠(yuǎn)指分割窗口最高層次的瀏覽器窗口;parent:包含當(dāng)前分割窗口的父窗口,本文將圍繞js中top、parent、frame進(jìn)行講述及他們的應(yīng)用案例2013-02-02
JavaScript中document對(duì)象使用詳解
這篇文章主要介紹了JavaScript中document對(duì)象使用詳解,總結(jié)的十分詳盡,需要的朋友可以參考下2015-01-01
深入理解JavaScript系列(47):對(duì)象創(chuàng)建模式(上篇)
這篇文章主要介紹了深入理解JavaScript系列(47):對(duì)象創(chuàng)建模式(上篇),本文講解了命名空間、定義依賴、私有屬性和私有方法 、Revelation模式、鏈模式等內(nèi)容,需要的朋友可以參考下2015-03-03
js setTimeout 常見(jiàn)問(wèn)題小結(jié)
主要包括this指向問(wèn)題、向setTimeout傳入?yún)?shù)等相關(guān)問(wèn)題,下面與大家分享下以上問(wèn)題的解決方法,感興趣的朋友可以參考下2013-08-08

