1.document.write(""); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document->html->(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window->(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËصÄÃû³ÆºÍÖµ:document.getElementByIdx_x("±íµ¥ÖÐÔªËصÄIDºÅ").name(»òvalue)
6.Ò»¸öСдת´óдµÄJS: document.getElementByIdx_x("output").value =
document.getElementByIdx_x("input").value.toUpperCase();
7.JSÖеÄÖµÀàÐÍ:String,Number,Boolean,Null,Object,Function
8.JSÖеÄ×Ö·ûÐÍת»»³ÉÊýÖµÐÍ:parseInt(),parseFloat()
9.JSÖеÄÊý×Öת»»³É×Ö·ûÐÍ:(""+±äÁ¿)
10.JSÖеÄÈ¡×Ö·û´®³¤¶ÈÊÇ:(length)
11.JSÖеÄ×Ö·ûÓë×Ö·ûÏàÁ¬½ÓʹÓÃ+ºÅ.
12.JSÖеıȽϲÙ×÷·ûÓÐ:==µÈÓÚ,!=²»µÈÓÚ,>,>=,<.<=
13.JSÖÐÉùÃ÷±äÁ¿Ê¹ÓÃ:varÀ´½øÐÐÉùÃ÷
14.JSÖеÄÅжÏÓï¾ä½á¹¹:if(condition){}else{}
15.JSÖеÄÑ»·½á¹¹:for([initial expression];[condition];[upadte
expression]) {inside loop}
16.Ñ»·ÖÐÖ¹µÄÃüÁîÊÇ:break
17.JSÖеĺ¯Êý¶¨Òå:function
functionName([parameter],...){statement[s]}
18.µ±ÎļþÖгöÏÖ¶à¸öform±íµ¥Ê±.¿ÉÒÔÓÃdocument.forms[0],document.forms[1]À´´úÌæ.
19.´°¿Ú:´ò¿ª´°¿Úwindow.open(), ¹Ø±ÕÒ»¸ö´°¿Ú:window.close(), ´°¿Ú±¾Éí:self
20.״̬À¸µÄÉèÖÃ:window.status="×Ö·û";
21.µ¯³öÌáʾÐÅÏ¢:window.alert("×Ö·û");
22.µ¯³öÈ·ÈÏ¿ò:window.confirm();
23.µ¯³öÊäÈëÌáʾ¿ò:window.prompt();
24.Ö¸¶¨µ±Ç°ÏÔʾÁ´½ÓµÄλÖÃ:window.location.href="/blog/URL"
25.È¡³ö´°ÌåÖеÄËùÓÐ±íµ¥µÄÊýÁ¿:document.forms.length
26.¹Ø±ÕÎĵµµÄÊä³öÁ÷:document.close();
27.×Ö·û´®×·¼ÓÁ¬½Ó·û:+=
28.´´½¨Ò»¸öÎĵµÔªËØ:document.createElement_x(),document.createTextNode()
29.µÃµ½ÔªËصķ½·¨:document.getElementByIdx_x()
30.ÉèÖÃ±íµ¥ÖÐËùÓÐÎı¾Ð͵ijÉÔ±µÄֵΪ¿Õ:
var form = window.document.forms[0]
for (var i = 0; i<form.elements.length;i++){
if (form.elements[i].type == "text"){
form.elements[i].value = "";
}
}
31.¸´Ñ¡°´Å¥ÔÚJSÖÐÅжÏÊÇ·ñÑ¡ÖÐ:document.forms[0].checkThis.checked
(checkedÊôÐÔ´ú±íΪÊÇ·ñÑ¡Öзµ»ØTRUE»òFALSE)
32.µ¥Ñ¡°´Å¥×é(µ¥Ñ¡°´Å¥µÄÃû³Æ±ØÐëÏàͬ):È¡µ¥Ñ¡°´Å¥×éµÄ³¤¶Èdocument.forms[0].groupName.length
33.µ¥Ñ¡°´Å¥×éÅжÏÊÇ·ñ±»Ñ¡ÖÐÒ²ÊÇÓÃchecked.
34.ÏÂÀÁбí¿òµÄÖµ:document.forms[0].selectName.options[n].value
(nÓÐʱÓÃÏÂÀÁбí¿òÃû³Æ¼ÓÉÏ.selectedIndexÀ´È·¶¨±»Ñ¡ÖеÄÖµ)
35.×Ö·û´®µÄ¶¨Òå:var myString = new String("This is lightsword");
36.×Ö·û´®×ª³É´óд:string.toUpperCase();
×Ö·û´®×ª³ÉСд:string.toLowerCase();
37.·µ»Ø×Ö·û´®2ÔÚ×Ö·û´®1ÖгöÏÖµÄλÖÃ:String1.indexOf("String2")!=-1Ôò˵Ã÷ûÕÒµ½.
38.È¡×Ö·û´®ÖÐÖ¸¶¨Î»ÖõÄÒ»¸ö×Ö·û:StringA.charAt(9);
39.È¡³ö×Ö·û´®ÖÐÖ¸¶¨ÆðµãºÍÖÕµãµÄ×Ó×Ö·û´®:stringA.substring(2,6);
40.Êýѧº¯Êý:Math.PI(·µ»ØÔ²ÖÜÂÊ),Math.SQRT2(·µ»Ø¿ª·½),Math.max(value1,value2)·µ»ØÁ½¸öÊýÖеÄ×îÔÚÖµ,Math.pow(value1,10)·µ»Øvalue1µÄÊ®´Î·½,Math.round(value1)ËÄÉáÎåÈ뺯Êý,Math.floor(Math.random()*(n+1))·µ»ØËæ»úÊý
41.¶¨ÒåÈÕÆÚÐͱäÁ¿:var today = new Date();
42.ÈÕÆÚº¯ÊýÁбí:dateObj.getTime()µÃµ½Ê±¼ä,dateObj.getYear()µÃµ½Äê·Ý,dateObj.getFullYear()µÃµ½ËÄλµÄÄê·Ý,dateObj.getMonth()µÃµ½Ô·Ý,dateObj.getDate()µÃµ½ÈÕ,dateObj.getDay()µÃµ½ÈÕÆÚ¼¸,dateObj.getHours()µÃµ½Ð¡Ê±,dateObj.getMinutes()µÃµ½·Ö,dateObj.getSeconds()µÃµ½Ãë,dateObj.setTime(value)ÉèÖÃʱ¼ä,dateObj.setYear(val)ÉèÖÃÄê,dateObj.setMonth(val)ÉèÖÃÔÂ,dateObj.setDate(val)ÉèÖÃÈÕ,dateObj.setDay(val)ÉèÖÃÐÇÆÚ¼¸,dateObj.setHoursÉèÖÃСʱ,dateObj.setMinutes(val)ÉèÖ÷Ö,dateObj.setSeconds(val)ÉèÖÃÃë
[×¢Òâ:´ËÈÕÆÚʱ¼ä´Ó0¿ªÊ¼¼Æ]
43.FRAMEµÄ±íʾ·½Ê½:
[window.]frames[n].ObjFuncVarName,frames["frameName"].ObjFuncVarName,frameName.ObjFuncVarName
44.parent´ú±í¸¸Ç׶ÔÏó,top´ú±í×¶Ë¶ÔÏó
45.´ò¿ª×Ó´°¿ÚµÄ¸¸´°¿ÚΪ:opener
46.±íʾµ±Ç°ËùÊôµÄλÖÃ:this
47.µ±ÔÚ³¬Á´½ÓÖе÷ÓÃJSº¯ÊýʱÓÃ:(javascript :)À´¿ªÍ·ºóÃæ¼Óº¯ÊýÃû
48.ÔÚÀϵÄä¯ÀÀÆ÷Öв»Ö´ÐдËJS:<!-- //-->
49.ÒýÓÃÒ»¸öÎļþʽµÄJS:<script type="text/javascript"
src="/blog/aaa.js"></script>
50.Ö¸¶¨ÔÚ²»Ö§³Ö½Å±¾µÄä¯ÀÀÆ÷ÏÔʾµÄHTML:<noscript></noscript>
51.µ±³¬Á´ºÍONCLICKʼþ¶¼ÓÐʱ,ÔòÀÏ°æ±¾µÄä¯ÀÀÆ÷תÏòa.html,·ñÔòתÏòb.html.Àý:<a
href="/blog/a.html"/blog/b.html";return
false">dfsadf</a>
52.JSµÄÄÚ½¨¶ÔÏóÓÐ:Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RangeError,ReferenceError,RegExp,String,SyntaxError,TypeError,URIError
53.JSÖеĻ»ÐÐ:\n
54.´°¿ÚÈ«ÆÁ´óС:<script>function
fullScreen(){
this.moveTo(0,0);this.outerWidth=screen.availWidth;this.outerHeight=screen.availHeight;}window.maximize=fullScreen;</script>
55.JSÖеÄall´ú±íÆäϲãµÄÈ«²¿ÔªËØ
56.JSÖеĽ¹µã˳Ðò:document.getElementByIdx_x("±íµ¥ÔªËØ").tabIndex = 1
57.innerHTMLµÄÖµÊÇ±íµ¥ÔªËصÄÖµ:Èç<p>"how are
<em>you</em>"</p>,ÔòinnerHTMLµÄÖµ¾ÍÊÇ:how
are
<em>you</em>
58.innerTEXTµÄÖµºÍÉÏÃæµÄÒ»Ñù,Ö»²»¹ý²»»á°Ñ<em>ÕâÖÖ±ê¼ÇÏÔʾ³öÀ´.
59.contentEditable¿ÉÉèÖÃÔªËØÊÇ·ñ¿É±»ÐÞ¸Ä,isContentEditable·µ»ØÊÇ·ñ¿ÉÐ޸ĵÄ״̬.
60.isDisabledÅжÏÊÇ·ñΪ½ûֹ״̬.disabledÉèÖýûֹ״̬
61.lengthÈ¡µÃ³¤¶È,·µ»ØÕûÐÍÊýÖµ
62.addBehavior()ÊÇÒ»ÖÖJSµ÷ÓõÄÍⲿº¯ÊýÎļþÆäÀ©Õ¹ÃûΪ.htc
63.window.focus()ʹµ±Ç°µÄ´°¿ÚÔÚËùÓд°¿Ú֮ǰ.
64.blur()ָʧȥ½¹µã.ÓëFOCUS()Ïà·´.
65.select()Ö¸ÔªËØΪѡÖÐ״̬.
66.·ÀÖ¹Óû§¶ÔÎı¾¿òÖÐÊäÈëÎı¾:onfocus="this.blur()"
67.È¡³ö¸ÃÔªËØÔÚÒ³ÃæÖгöÏÖµÄÊýÁ¿:document.all.tags("div(»òÆäËüHTML±ê¼Ç·û)").length
68.JSÖзÖΪÁ½ÖÖ´°ÌåÊä³ö:ģ̬ºÍ·Çģ̬.window.showModaldialog(),window.showModeless()
69.״̬À¸ÎÄ×ÖµÄÉèÖÃ:window.status='ÎÄ×Ö',ĬÈϵÄ״̬À¸ÎÄ×ÖÉèÖÃ:window.defaultStatus =
'ÎÄ×Ö.';
70.Ìí¼Óµ½ÊղؼÐ:external.AddFavorite("http://www.dannyg.com","jaskdlf");
71.JSÖÐÓöµ½½Å±¾´íÎóʱ²»×öÈκβÙ×÷:window.onerror = doNothing;
Ö¸¶¨´íÎó¾ä±úµÄÓ﷨Ϊ:window.onerror = handleError;
72.JSÖÐÖ¸¶¨µ±Ç°´ò¿ª´°¿ÚµÄ¸¸´°¿Ú:window.opener,Ö§³Öopener.opener...µÄ¶àÖؼÌÐø.
73.JSÖеÄselfÖ¸µÄÊǵ±Ç°µÄ´°¿Ú
74.JSÖÐ״̬À¸ÏÔʾÄÚÈÝ:window.status="ÄÚÈÝ"
75.JSÖеÄtopÖ¸µÄÊÇ¿ò¼Ü¼¯ÖÐ×²ãµÄ¿ò¼Ü
76.JSÖйرյ±Ç°µÄ´°¿Ú:window.close();
77.JSÖÐÌá³öÊÇ·ñÈ·ÈϵĿò:if(confirm("Are you
sure?")){alert("ok");}else{alert("Not Ok");}
78.JSÖеĴ°¿ÚÖض¨Ïò:window.navigate("http://www.sina.com.cn");
79.JSÖеĴòÓ¡:window.print()
80.JSÖеÄÌáʾÊäÈë¿ò:window.prompt("message","defaultReply");
81.JSÖеĴ°¿Ú¹ö¶¯Ìõ:window.scroll(x,y)
82.JSÖеĴ°¿Ú¹ö¶¯µ½Î»ÖÃ:window.scrollby
83.JSÖÐÉèÖÃʱ¼ä¼ä¸ô:setInterval("expr",msecDelay)»òsetInterval(funcRef,msecDelay)»òsetTimeout
84.JSÖеÄģ̬ÏÔʾÔÚIE4+ÐÐ,ÔÚNNÖв»ÐÐ:showModalDialog("URL"[,arguments][,features]);
85.JSÖеÄÍ˳ö֮ǰʹÓõľä±ú:function verifyClose(){event.returnValue="we
really like you and hope you will stay longer.";}}
window.onbeforeunload=verifyClose;
86.µ±´°ÌåµÚÒ»´Îµ÷ÓÃʱʹÓõÄÎļþ¾ä±ú:onload()
87.µ±´°Ìå¹Ø±Õʱµ÷ÓõÄÎļþ¾ä±ú:onunload()
88.window.locationµÄÊôÐÔ:
protocol(http:),hostname(),port(80),host(:80),pathname("/a/a.html"),hash("#giantGizmo",Ö¸Ìøתµ½ÏàÓ¦µÄê¼Ç),href(È«²¿µÄÐÅÏ¢)
89.window.location.reload()ˢе±Ç°Ò³Ãæ.
90.window.history.back()·µ»ØÉÏÒ»Ò³,window.history.forward()·µ»ØÏÂÒ»Ò³,window.history.go(·µ»ØµÚ¼¸Ò³,Ò²¿ÉÒÔʹÓ÷ÃÎʹýµÄURL)
91.document.write()²»»»ÐеÄÊä³ö,document.writeln()»»ÐÐÊä³ö
92.document.body.noWrap=true;·ÀÖ¹Á´½ÓÎÄ×ÖÕÛÐÐ.
93.±äÁ¿Ãû.charAt(µÚ¼¸Î»),È¡¸Ã±äÁ¿µÄµÚ¼¸Î»µÄ×Ö·û.
94."abc".charCodeAt(µÚ¼¸¸ö),·µ»ØµÚ¼¸¸ö×Ö·ûµÄASCiiÂëÖµ.
95.×Ö·û´®Á¬½Ó:string.concat(string2),»òÓÃ+=½øÐÐÁ¬½Ó
96.±äÁ¿.indexOf("×Ö·û",ÆðʼλÖÃ),·µ»ØµÚÒ»¸ö³öÏÖµÄλÖÃ(´Ó0¿ªÊ¼¼ÆËã)
97.string.lastIndexOf(searchString[,startIndex])×îºóÒ»´Î³öÏÖµÄλÖÃ.
98.string.match(regExpression),ÅжÏ×Ö·ûÊÇ·ñÆ¥Åä.
99.string.replace(regExpression,replaceString)Ìæ»»ÏÖÓÐ×Ö·û´®.
100.string.split(·Ö¸ô·û)·µ»ØÒ»¸öÊý×é´æ´¢Öµ.
101.string.substr(start[,length])È¡´ÓµÚ¼¸Î»µ½Ö¸¶¨³¤¶ÈµÄ×Ö·û´®.
102.string.toLowerCase()ʹ×Ö·û´®È«²¿±äΪСд.
103.string.toUpperCase()ʹȫ²¿×Ö·û±äΪ´óд.
104.parseInt(string[,radix(´ú±í½øÖÆ)])Ç¿ÖÆת»»³ÉÕûÐÍ.
105.parseFloat(string[,radix])Ç¿ÖÆת»»³É¸¡µãÐÍ.
106.isNaN(±äÁ¿):²âÊÔÊÇ·ñΪÊýÖµÐÍ.
107.¶¨Òå³£Á¿µÄ¹Ø¼ü×Ö:const,¶¨Òå±äÁ¿µÄ¹Ø¼ü×Ö:var
¡¡