|
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>Document.writeln()方法</title>
<script language="Javascript">
function createsummary()
{
win2=open("","window2")
//win2.document.open("text/plain")
win2.document.writeln("title"+document.title)
win2.document.close()
}
</script>
</head>
<body>
<a name="#top"></a>
<form>
<input type="button" name="help" value="help"onClick="createsummary()">
</form>
<body>
</html>
說(shuō)一下知識(shí)要點(diǎn)吧:
1:JavaScript是一種區(qū)分大小寫(xiě)的語(yǔ)言。
2:建議每寫(xiě)一行要用‘;';
3:命名第一個(gè)字母必須是字母、下劃線或‘$';
4:在JavaScript中聲明變量用var,而且是永久性的;
5:沒(méi)有塊級(jí)作用域。例如:
Var scope="globle";function f(){
alert(scope); //顯示“underfined"而不是"globle"
Var scope="local";
alert(scope);
}
F();與下面的代碼實(shí)例意義相同 Var scope="globle";
function f(){
Var scope;
alert(scope); //顯示“underfined"而不是"globle"
Var scope="local";
alert(scope);
}
F();
建議:將所有的變量聲明集中起來(lái)放置在函數(shù)的開(kāi)頭是一個(gè)很好的編程習(xí)慣。
6:ECMAScript標(biāo)準(zhǔn)中規(guī)定函數(shù)不能重載,例如
function doadd(i){
alert(i);
}
function doadd(i){
alert(i);
}
doadd(10);
真正執(zhí)行的是后一個(gè)函數(shù),第二個(gè)覆蓋了第一個(gè)函數(shù);
7:arguments對(duì)象的使用。
function doAdd()If(arguments.length==1){
alert(arguments[0]+10);
}
If(arguments.length==2){
alert(arguments[0]+arguments[0);
}
doAdd(10);
doAdd(10,20);
運(yùn)行效果:略……
JavaScript技術(shù):JavaScript的學(xué)習(xí)入門(mén)整理篇第1/3頁(yè),轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。