Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScript×Ö·û´®º¯Êý´óÈ«


JS×Ô´øº¯Êý
concat
½«Á½¸ö»ò¶à¸ö×Ö·ûµÄÎı¾×éºÏÆðÀ´£¬·µ»ØÒ»¸öеÄ×Ö·û´®¡£
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®µÚÒ»´¦³öÏÖµÄË÷Òý£¨´Ó×óµ½ÓÒËÑË÷£©¡£Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = a.indexOf("l");
//index1 = 2
var index2 = a.indexOf("l",3);
//index2 = 3
charAt
·µ»ØÖ¸¶¨Î»ÖõÄ×Ö·û¡£
var get_char = a.charAt(0);
//get_char = "h"
lastIndexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®×îºóÒ»´¦³öÏÖµÄË÷Òý£¨´ÓÓÒµ½×óËÑË÷£©£¬Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = lastIndexOf('l');
//index1 = 3
var index2 = lastIndexOf('l',2)
//index2 = 2
match
¼ì²éÒ»¸ö×Ö·û´®Æ¥ÅäÒ»¸öÕýÔò±í´ïʽÄÚÈÝ£¬Èç¹ûôÓÐÆ¥Åä·µ»Ø null¡£
var re = new RegExp(/^\w+$/);
var is_alpha1 = a.match(re);
//is_alpha1 = "hello"
var is_alpha2 = b.match(re);
//is_alpha2 = null
substring
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͽáÊøλÖá£
var sub_string1 = a.substring(1);
//sub_string1 = "ello"
var sub_string2 = a.substring(1,4);
//sub_string2 = "ell"
substr
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͳ¤¶È
var sub_string1 = a.substr(1);
//sub_string1 = "ello"
var sub_string2 = a.substr(1,4);
//sub_string2 = "ello"
replace
ÓÃÀ´²éÕÒÆ¥ÅäÒ»¸öÕýÔò±í´ïʽµÄ×Ö·û´®£¬È»ºóʹÓÃÐÂ×Ö·û´®´úÌæÆ¥ÅäµÄ×Ö·û´®¡£
var result1 = a.replace(re,"Hello");
//result1 = "Hello"
var result2 = b.replace(re,"Hello");
//result2 = ",world"
search
Ö´ÐÐÒ»¸öÕýÔò±í´ïʽƥÅä²éÕÒ¡£Èç¹û²éÕҳɹ¦£¬·µ»Ø×Ö·û´®ÖÐÆ¥ÅäµÄË÷ÒýÖµ¡£·ñÔò·µ»Ø -1 ¡£
var index1 = a.search(re);
//index1 = 0
var index2 = b.search(re);
//index2 = -1
slice
ÌáÈ¡×Ö·û´®µÄÒ»²¿·Ö£¬²¢·µ»ØÒ»¸öÐÂ×Ö·û´®£¨Óë substring Ïàͬ£©¡£
var sub_string1 = a.slice(1);
//sub_string1 = "ello"
var sub_string2 = a.slice(1,4);
//sub_string2 = "ell"
split
ͨ¹ý½«×Ö·û´®»®·Ö³É×Ó´®£¬½«Ò»¸ö×Ö·û´®×ö³ÉÒ»¸ö×Ö·û´®Êý×é¡£
var arr1 = a.split("");
//arr1 = [h,e,l,l,o]
length
·µ»Ø×Ö·û´®µÄ³¤¶È£¬Ëùν×Ö·û´®µÄ³¤¶ÈÊÇÖ¸Æä°üº¬µÄ×Ö·ûµÄ¸öÊý¡£
var len = a.length();
//len = 5
toLowerCase
½«Õû¸ö×Ö·û´®×ª³ÉСд×Öĸ¡£
var lower_stri


Ïà¹ØÎĵµ£º

³£¼ûfirefox²»Ö§³ÖµÄJavaScriptÎÊÌâ

<a href="#" onclick="ChildNode(this);">aaa</a>Òª¸ÄΪ
<a href="#" onclick="ChildNode(event);">aaa</a>
ÎÞ·¨È¡µÃthis¶ÔÏó£¬ÒªÓÃÒÔÏ·½·¨À´È¡µÃ¡£
function ChildNode(e)
{
var evt = e ? e : (window.event ? window.event : null); //´Ë·½·¨ÎªÁËÔÚfirefoxÖеļæÈÝ
var node = evt.srcEl ......

¶ÔÓÚJavaScriptµÄ Stack overflow at line ´íÎó×ܽá

¶ÔÓÚJavaScriptµÄ Stack overflow at line ´íÎó×ܽá
¸Ã´íÎóÖ»ÔÚIEÖгöÏÖ£¬³öÏÖ¸ÃÌáʾµÄÔ­ÒòÖ÷ÒªÓÐÁ½ÖÖ£º
     1. Öض¨ÒåÁËϵͳµÄ´¥·¢Ê¼þÃû³Æ×÷Ϊ×Ô¶¨Ò庯ÊýÃûÈ磺  onclick / onsubmit ...  ¶¼ÊÇϵͳ±£ÁôµÄʼþÃû³Æ£¬²»ÔÊÐí×÷ΪÖض¨Ò庯ÊýÃû³Æ¡£
     2. ......

ÍøÒ³ÖÆ×÷Javascript¾­µäС¼¼ÇÉ×ܽá


ÍøÒ³ÖÆ×÷Javascript¾­µäС¼¼ÇÉ×ܽá
http://www.webjx.com  ¸üÐÂÈÕÆÚ£º2007-10-12 01:25  ³ö´¦£ºÍøÒ³½ÌѧÍø  ×÷ÕߣºÕ¾³¤ÕûÀí
ÿһÏÊÇJSÖеÄС¼¼ÇÉ£¬µ«Ê®·ÖµÄʵÓã¡
1.document.write(”"); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document->html->(head,body)
4.Ò»¸öä¯ÀÀÆ ......

javascript refresh page ¼¸ÖÖÒ³Ãæˢеķ½·¨

JavascriptË¢ÐÂÒ³ÃæµÄ¼¸ÖÖ·½·¨£º
1    history.go(0)
2    location.reload()
3    location=location
4    location.assign(location)
5    document.execCommand('Refresh')
6    window.navigate(location)
7& ......

Javascript Ö®apply()

1¡¢¶ÔÏóµÄ¼Ì³Ð£¬Ò»°ãµÄ×ö·¨ÊǸ´ÖÆ£ºObject.extend
prototype.jsµÄʵÏÖ·½Ê½ÊÇ£º
Object.extend = function(destination, source){
for (property in source) {
destination[property] = source[property];
}
return destination;
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ