JavaScript£ºprototypeÊôÐÔʹÓ÷½·¨
Ò»¡¢»ù±¾Ê¹Ó÷½·¨
prototypeÊôÐÔ¿ÉËãÊÇJavaScriptÓëÆäËûÃæÏò¶ÔÏóÓïÑÔµÄÒ»´ó²»Í¬Ö®´¦¡£
¼ò¶øÑÔÖ®£¬prototype¾ÍÊǓһ¸ö¸øÀàµÄ¶ÔÏóÌí¼Ó·½·¨µÄ·½·¨”£¬Ê¹ÓÃprototypeÊôÐÔ£¬¿ÉÒÔ¸øÀද̬µØÌí¼Ó·½·¨£¬ÒÔ±ãÔÚJavaScriptÖÐʵÏÖ“¼Ì³Ð”µÄЧ¹û¡£
¾ßÌåÀ´Ëµ£¬prototype ÊÇÔÚ IE 4 ¼°ÆäÒÔºó°æ±¾ÒýÈëµÄÒ»¸öÕë¶ÔÓÚijһÀàµÄ¶ÔÏóµÄ·½·¨£¬µ±ÄãÓÃprototype±àдһ¸öÀàºó£¬Èç¹ûnewÒ»¸öеĶÔÏó£¬ä¯ÀÀÆ÷»á×Ô¶¯°ÑprototypeÖеÄÄÚÈÝÌæÄ㸽¼ÓÔÚ¶ÔÏóÉÏ¡£ÕâÑù£¬Í¨¹ýÀûÓÃprototype¾Í¿ÉÒÔÔÚJavaScriptÖÐʵÏÖ³ÉÔ±º¯ÊýµÄ¶¨Ò壬ÉõÖÁÊÇ“¼Ì³Ð”µÄЧ¹û¡£
Ò»¸ö¼òµ¥µÄʾÀýÈçÏ£º
view plaincopy to clipboardprint?
Number.prototype.add = function(num){return(this+num);}
Number.prototype.add = function(num){return(this+num);}
ÕâÊǶÔÒÑÓÐÀàÌí¼Ó·½·¨¡£ÕâÑùд£¬¿ÉÒÔÔöÇ¿ÒÑÓÐÀàµÄ¹¦ÄÜ£¬ÀýÈç¿ÉÒÔ¸øArrayÀàÔö¼Ópush·½·¨ÈçÏ£º
view plaincopy to clipboardprint?
Array.prototype.push = function(new_element){
this[this.length]=new_element;
return this.length;
}
Array.prototype.push = function(new_element){
this[this.length]=new_element;
return this.length;
}
¶ÔÓÚ×Ô¶¨ÒåµÄÀࣨ»òÕ߳ƺ¯Êý¶ÔÏ󣩣¬Ò²¿ÉÒÔÕâÑùд£º
view plaincopy to clipboardprint?
function MyApplication() {
this.counter = 0;
this.map = new GMap2(document.getElementById("map_canvas"));
this.map.setCenter(new GLatLng(39.917,116.397), 14);
GEvent.bind(this.map, "click", this, this.onMapClick);
}
MyApplication.prototype.onMapClick = fu
Ïà¹ØÎĵµ£º
ÒýÓÃÊÇÒ»¸öÖ¸Ïò¶ÔÏóʵ¼ÊλÖõÄÖ¸Õë¡£
Àý1£º
var obj = new Object();
var objRef = obj; //objÓëobjRefÖ¸Ïòͬһ¸ö¶ÔÏó,objRefÊÇÒ»¸öÒýÓÃ
×ÔÐ޸ģ¨self-modifying£©
Àý2£º
var items = new Array("one","two","three");
var itemsRef = items; //´´½¨Ò»¸öÒýÓÃ
items.push("four");
alert(items.length == items ......
ʼþÔ´¶ÔÏó
event.srcElement.tagName
event.srcElement.type
²¶»ñÊÍ·Å
event.srcElement.setCapture();
event.srcElement.releaseCapture();
ʼþ°´¼ü
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
ʼþ·µ»ØÖµ
event.returnValue
Êó±êλÖÃ
event.x
event.y
´° ......
ÎÒÃÇÔÚjspÒ³ÃæÉϵÄjs½Å±¾ÖпÉÒÔµ÷ÑÐjava´úÂ룬±ÈÈ磬ÎÒÃÇÐèÒªÔÙjsÖÐÓÃalertº¯ÊýÏÔʾ·þÎñÆ÷¶Ë·¢Ë͹ýÀ´µÄij¸ö×Ö·û´®ÄÇôÎÒÃÇ¿ÉÒÔÕâÑù×ö
tomcat주
ÔÚ·þÎñÆ÷¶ËÎÒÃÇÓÐrequest.setAttribute("name","abc");
ÄÇôÎÒÒªÔÚÒ³ÃæÉÏÓÃalertÏÔʾµÄ»°£¬ÓÐÁ½ÖÖ·½Ê½£º
1¡¢Ê¹ÓÃEL±í´ïʽ
ÔÚEl±í´ïʽµÄÍâÃæÓÃÒýºÅ¼´¿É£º
<scri ......
prototype ÊÇÔÚ IE 4 ¼°ÆäÒÔºó°æ±¾ÒýÈëµÄÒ»¸öÕë¶ÔÓÚijһÀàµÄ¶ÔÏóµÄ·½·¨£¬¶øÇÒÌØÊâµÄµØ·½±ãÔÚÓÚ£ºËüÊÇÒ»¸ö¸øÀàµÄ¶ÔÏóÌí¼Ó·½·¨µÄ·½·¨£¡ÕâÒ»µã¿ÉÄÜÌýÆðÀ´»áÓеãÂÒ£¬±ð¼±£¬ÏÂÃæÎÒ±ãͨ¹ýʵÀý¶ÔÕâÒ»ÌØÊâµÄ·½·¨×÷ÒÑϽ²½â£º
¡¡¡¡Ê×ÏÈ£¬ÎÒÃÇÒªÏÈÁ˽âÒ»ÏÂÀàµÄ¸ÅÄJavaScript ±¾ÉíÊÇÒ»ÖÖÃæÏò¶ÔÏóµÄÓïÑÔ£¬ËüËùÉæ¼°µÄÔªËØ¸ù¾ÝÆäÊôÐÔµ ......