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

javascriptÉè¼Æģʽ_µÚ¶þ²¿·Ö_Á´Ê½µ÷ÓÃ

 Á´Ê½µ÷ÓÃÊÇÒ»¸öÓï·¨ÕÐÊý.°üº¬Á½¸ö²¿·Ö:
1.Ò»¸ö´´½¨HTMLÔªËصĶÔÏóµÄ¹¤³§
2.¶ÔÕâ¸öHTMLÔªËØÖ´ÐеIJÙ×÷µÄ·½·¨
[¸öÈËÀí½â:½«HTMLÔªËØ°ü×°³É¶ÔÏó,ÔÚ¶ÔÏóÉÏÌí¼Ó·½·¨(ÖصãÔÚreturn this)]
¹¹ÔìÆ÷
(function(){
//Use a private class
function _$(els){
this.elements = [];
for(var i=0; i<els.length; i++){
var element = els[i];
if(typeof element === "string"){
element = document.getElementById(element);
}
this.elements.push(element);
}
}
//
_$.prototype = {
each : function(fn){
for(var i=0; i<this.elements.length; i++){
fn.call(this,this.elements[i]);
}
return this;
},
setStyle : function(prop,val){
this.each(function(el){
el.style[prop] = val;
});
return this;
},
show : function(){
var that = this;
this.each(function(el){
that.setStyle("display","bloc");
});
return this;
},
addEvent : function(type,fn){
var add = function(el){
if(window.addEventListener){
el.addEventListener(type,fn,false);
}
else if(window.attachEvent){
el.attachEvent("on"+type,fn);
}
}
this.each(function(el){
add(el);
})
return this;
}
};
//the public interface remains the same
window.$ = function(){
return new _$(arguments);
}
})()

ʹÓûص÷´ÓÖ§³ÖÁ´Ê½µ÷Óõķ½·¨»ñÈ¡Êý¾Ý
Á´Ê½µ÷ÓúÜÊʺÏÓÚ¸³ÖµÆ÷·½·¨,µ«¶ÔÓÚÈ¡ÖµÆ÷·½·¨,Äã¿ÉÄÜ»áÏ£ÍûËüÃÇ·µ»ØÄãÒªµÄÊý¾Ý¶ø²»ÊÇ·µ»Øthis.
window.API2 = window.API2 || function(){
var name = "hell";
this.setName = function(newName){
name = newName;
return this;
};
this.getName = function(callback){
callback.call(this,name);
return this;
}
};
var o2 = new API2;
o2.getName(console.log).setName("Menw").getName(console.log);
  
 


Ïà¹ØÎĵµ£º

JavaScriptÖÐescapeº¯Êý

JavaScriptÖÐescape() º¯Êý¿É¶Ô×Ö·û´®½øÐбàÂ룬ÕâÑù¾Í¿ÉÒÔÔÚËùÓеļÆËã»úÉ϶ÁÈ¡¸Ã×Ö·û´®¡£Ê¹Ó÷½·¨£º
escape(charString)
charstringÊDZØÑ¡ÏҪ±»×ªÒå»ò±àÂëµÄ×Ö·û´®¡£
escape ·½·¨·µ»ØÒ»¸ö°üº¬ÁË charstring ÄÚÈݵÄ×Ö·û´®Öµ£¨ Unicode ¸ñʽ£©¡£ËùÓпոñ¡¢±êµã¡¢ÖØÒô·ûºÅÒÔ¼°ÆäËû·Ç ASCII ×Ö·û¶¼Óà %xx ±àÂë´úÌ棬ÆäÖ ......

JavascriptÊý×é¼°Æä²Ù×÷


±¾ÎĽéÉÜÈçϼ¸¸ö·½ÃæµÄÄÚÈÝ:
1.ÈçºÎ´´½¨Êý×é
2.ÈçºÎ¶ÔÊý×é½øÐвÙ×÷£¨Ìí¼Ó,ɾ³ý,¶ÁÈ¡)
3.Êý×é³£¼û·½·¨ºÍÊôÐÔ
ÈçºÎ´´½¨Ò»¸öÊý×é,Ò»°ãµØ¸ù¾Ý³õʼ»¯É趨¼òµ¥·ÖΪ3ÖÖ:
1.µ¥´¿´´½¨Êý×é:
var arr=new Array();
Òªµã:ÓÃnew¹Ø¼ü×Ö´´½¨Êý×é¶ÔÏóArray(),Array()¶ÔÏóÊÇÒ»¸ö±¾µØÀà,¿ÉÒÔÓÃnew´´½¨Ò»¸ö¶ÔÏóºóʹÓÃ
2.´´½¨Êý×éµÄÍ ......

JavascriptÖÐ×î³£ÓõÄ55¸ö¾­µä¼¼ÇÉ

 1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)><td>no</table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false" ²»×¼Õ³Ìù
4. oncopy="return false;" oncut="re ......

JSͨÓÃ±íµ¥ÑéÖ¤º¯Êý,»ùÓÚjavascriptÕýÔò±í´ïʽ

 ±íµ¥µÄÑéÖ¤ÔÚʵ¼ÊµÄ¿ª·¢µ±ÖÐÊǼþºÜ·³ËöÓÖÎÞȤµÄÊÂÇé
½ñÌìÔÚ×öÒ»¸öСÏîÄ¿µÄʱºò,ÐèÒªJSÑéÖ¤,Ñ°ÕÒµ½Ò»¸ö±È½ÏºÃµÄ¶«Î÷
µØÖ·ÈçÏÂ:
http://blog.csdn.net/goodfunman/archive/2005/10/21/513338.aspx
http://blog.csdn.net/yhl_621/archive/2006/03/04/615273.aspx
http://blog.csdn.net/NetDreamwing/archive/2004/1 ......

javascript »ñÈ¡URL²ÎÊý

function getQueryString(queryStringName)
{
 var returnValue="";
 var URLString=new String(document.location);
 var serachLocation=-1;
 var queryStringLength=queryStringName.length;
 do
 {
  serachLocation=URLString.indexOf(queryStringName+"\=");
  if ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ