javascript¿ò¼ÜÖ®¼Ì³Ð»úÖÆ
´óÒ»µãµÄ¿ò¼Ü¶¼ÓÐÕâ¸ö¶«Î÷¡£PrototypeÔÀ´µÄ¼Ì³Ð»úÖƷdz£Èõ£¬ÎªÁËÓëmootools¶Ô¿¹Ò²Ç¿»¯ÁËÕâÒ»·½Ãæ¡£ÂҪÓÃÔÐͼ̳ÐÀ´Ä£·ÂÀà¼Ì³Ð£¬¶¼»ù±¾´æÔÚÒ»¸ö¿Ë¡º¯Êý¡£°Ñ¸¸ÀàµÄÔÐÍÊôÐÔ¸´ÖƵ½×ÓÀàÉÏÈ¥¡£ÀíÄîµÄ¶«Î÷ÔÝʱÕâô¶à£¬¶¯ÊÖʵ¼ùÒ»ÏÂ×îʵ¼Ê¡£ÎÒÃÇÉè¼ÆÒ»¸öÊý×éÀ࣬ӵÓÐÔÉúÊý×éµÄÄÜÁ¦ÓëÐÂÀ©Õ¹µÄÄÜÁ¦¡£
var isNumber = function(n){
return typeof n === 'number' && isFinite(n);
}
var vArray = function(){
if(arguments.length == 0){
return [];
}else if(arguments.length == 1 && isNumber(arguments[0])){
return new Array(arguments[0]);
}else if(arguments.length > 1){
return Array.prototype.slice.apply(arguments);
}
}
var a = vArray();
alert(a);
var b = vArray(7);
alert(b);
var c = vArray(1,3,"˾ͽÕýÃÀ",true);
alert(c);
ÔËÐдúÂë
ºÜÏÔÈ»ÕâÊǹ¤³§·½·¨£¬Éú³ÉµÄÔÉúÊý×飬Èç¹ûÒªÀ©Õ¹¶ø²»ÎÛȾÔÉúÊý×é¾ÍÓÖÒªÔÙ¼ÓÒ»ÖØ°ü×°¡£ÎÒÃÇ¿´¼Ì³ÐÊÇÔõÑùʵÏֵġ£ÕâÉæ¼°µ½Á½¸öÀ࣬ÔÉúÊý×éÀàÓëÐÂÊý×éÀà¡£ÏÈ¿´´úÂ룺
var Parent = function(){};
Parent.prototype = Array.prototype;
var Array2 = function(){};
Array2.prototype = new Parent;
Array2.prototype.newMethod = function(){
return "newMethod";
};
Array2.prototype.constructor = Array2;
var a = new Array2("dd",4);
alert(a.newMethod)
var b = new Array("dd",4);
alert(b.newMethod)
ÔËÐдúÂë
ÓÉÓÚjavascriptµÄÔÐÍÁ´µÄ¹Øϵ£¬ÎÒÃDz»ÄÜÖ±½Óvar Array2 = Array;var a = new Array2£»ÕâÑùÒ»µ©´ÓArray2µÄÔÐÍÌí¼Óз½·¨£¨Ìí¼Ó·½·¨¶¼½¨ÒéÍùÔÐÍÀï¼Ó£¬²»½¨Òé×ö³ÉÀà·½·¨£©Ê±£¬ArrayµÄÔÐÍÒ²±»¼ÓÉÏÁË£¬ÒòΪËüÃÇÊÇÔÚͬһÌõ´¬ÉÏ¡£ÎÒÃDZØÐë¶Ï¿ªËüÃÇ¡£ÓÚÊÇÎÒÃÇÐèÒªÒ»¸öParentº¯Êý×öÇŽӡ£ÎÒÃÇ¿ÉÒÔ˵ArrayΪĿ±ê¸¸À࣬ParentΪÕæÕý¸¸Àà¡£ÏÈ°ÑÄ¿±ê¸¸ÀàµÄÔÐ͸³¸øParentµÄÔÐÍ£¬ÕâÑùParent¾ÍÓµÓÐÆäËùÓй«¿ªµÄ·½·¨£¬È»ºóÎÒÃÇÔÙ°ÑÕâЩ·½·¨¸³¸øArray2¡£µ«ÕâʱArray2µÄʵÀýµÄconstructor ÈÔΪÔÉúµÄÊý×飬ÎÒÃÇÒªÐÞÕýһϣ¬Ò²¾ÍÊÇ°ÑËüµÄÔÐÍÉϵÄconstructorÊô
Ïà¹ØÎĵµ£º
¸Õ²ÅÒ»¸öÅóÓѸæËßÎÒËûµÄblogÓÑÇéÁ´½ÓÌ«¶àÁË£¬ËùÒÔ°ÑËùÓÐÁ´½Ó·Åµ½Ò»¸öDIVÖУ¬¼ÓÁ˸ö¹ö¶¯Ìõ£¬¿ÉÊÇËûÓÖ²»Ïëÿ´Î±ðÈËÀ´¿´£¬¿´µ½µÄ¶¼ÊÇÇ°Ã漸¸öÁ´½Ó£¬ÓÚÊÇÎÊÎÒÓÐûÓÐʲô°ì·¨£¬ÏëÁËÒ»¸ö£¬ºÇºÇ£¬ÕýºÃÓиö°ì·¨
styleºóÃæÓÃÓÚÏÞ¶¨DIVÑùʽ²¢¼Ó¹ö¶¯Ìõ£¬Õâ¸ö²»¶à˵
¹Ø¼üµÄµØ·½ÆäʵºÜ¼òµ¥£¬×îºóÁ½ÐÐJavascript¾ÍÊÇÁË£¬Æð×÷ÓõÄÖ»ÓÐ×îº ......
jQueryƬ¶Î£º
var
// Will speed up references to window, and allows munging its name.
window = this,
// Will speed up references to undefined, and allows munging its name.
undefined,
// Map over jQuery in case of overwrite
_jQuery = window.jQuery,
// Map over the $ in case of overwrit ......
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 ......
1. oncontextmenu="window.event.returnValue=false" ½«³¹µ×ÆÁ±ÎÊó±êÓÒ¼ü
<table border oncontextmenu=return(false)> <td>no </table> ¿ÉÓÃÓÚTable
2. <body onselectstart="return false"> È¡ÏûÑ¡È¡¡¢·ÀÖ¹¸´ÖÆ
3. onpaste="return false&quo ......
Ò»¡¢ÑéÖ¤Àà
1¡¢Êý×ÖÑéÖ¤ÄÚ
1.1 ÕûÊý
1.2 ´óÓÚ0µÄÕûÊý £¨ÓÃÓÚ´«À´µÄIDµÄÑéÖ¤)
1.3 ¸ºÕûÊýµÄÑéÖ¤
1.4 ÕûÊý²»ÄÜ´óÓÚiMax
1.5 ÕûÊý²»ÄÜСÓÚiMin
2¡¢Ê±¼äÀà
2.1 ¶Ìʱ¼ä£¬ÐÎÈç (13:04:06)
2.2 ¶ÌÈÕÆÚ£¬ÐÎÈç (2003-12-05)
2.3 ³¤Ê±¼ä£¬ÐÎÈç (2003-12-05 13:04:06)
2.4 Ö»ÓÐÄêºÍÔ¡£ÐÎÈç(2003-05,»òÕß2003-5)
2.5 ......