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

Javascriptʼþ¼àÌý¡¾ÕûÀí¡¿

FireFox : addEventListener()·½·¨ IE : attachEvent()·½·¨ ΪHTMLÔªËØÌí¼ÓÒ»¸öʼþ¼àÌý, ¶ø²»ÊÇÖ±½Ó¶ÔÔªËØµÄʼþÊôÐÔ£¨È磺onclick¡¢onmouseover£©¸³Öµ¡£ ÕâÁ½ÖÖ·½·¨´¦Àíʼþ»¹ÊÇÓкܴóÇø±ðµÄ£¡Ê¼þÊôÐÔÖ»Äܸ³ÖµÒ»ÖÖ·½·¨£¬¼´£º button1.onclick = function() { alert(1); };
button1.onclick = function() { alert(2); };
ÕâÑùºóÃæµÄ¸³ÖµÓï¾ä¾Í½«Ç°ÃæµÄonclickÊôÐÔ¸²¸ÇÁË¡£


    Javascriptʼþ¼àÌýʾÀý


²âÊÔ

///
/// Ìí¼Óʼþ¼àÌý
///
/// ÔØÌå
/// ʼþÀàÐÍ
/// ʼþº¯Êý
function addEventHandler(target, type, func) {
    if (target.addEventListener)
        target.addEventListener(type, func, false);
    else if (target.attachEvent)
        target.attachEvent("on" + type, func);
    else target["on" + type] = func;
} ///
/// ÒÆ³ýʼþ¼àÌý
///
/// ÔØÌå
/// ʼþÀàÐÍ
/// ʼþº¯Êý
function removeEventHandler(target, type, func) {
    if (target.removeEventListener)
        target.removeEventListener(type, func, false);
    else if (target.detachEvent)
        target.detachEvent("on" + type, func);
    else delete target["on" + type];
} var Button1 = document.getElementById("Button1");
var Button1Click = function() { alert(1); };
addEventHandler(Button1, "click",  Button1Click);
addEventHandler(Button1, "click", function() { alert(2); } );
addEventHandler(Button1, "click", function() { alert(3); } ); removeEventHandler(Button1, "click", function() { alert(2); } ); // ÒÆ²»³ö
removeEventHandler(Button1, "click", Button1Click); // ¿ÉÒÔÒÆ³ý



¶øÌí¼Óʼþ¼àÌý¾Í¿ÉÒÔ²¢ÐС£ ÌØ±ðÊǵ±ÍŶӺÏ×÷ʱ£¬Ê¼þ²¢Ð


Ïà¹ØÎĵµ£º

ʹÓÃjavascript´ò¿ªÄ£Ì¬¶Ô»°¿ò

¡¾×ª×Ô¡¿http://www.cnblogs.com/chenxizhang/archive/2009/05/27/1491049.html
1. ±ê×¼µÄ·½·¨
<script type="text/javascript">  
function openWin(src, width, height, showScroll){  
window.showModalDialog (src,"","location:No;status:No;help:No;dialogWidth:"+width+";dialogHei ......

JavaScript apply¡¢call·½·¨ºÍlengthÊôÐÔ

JavaScriptΪº¯Êý¶ÔÏó¶¨ÒåÁËÁ½¸ö·½·¨£ºapplyºÍcall£¬ËüÃǵÄ×÷Óö¼Êǽ«º¯Êý°ó¶¨µ½ÁíÍâÒ»¸ö¶ÔÏóÉÏÈ¥ÔËÐУ¬Á½Õß½öÔÚ¶¨Òå²ÎÊýµÄ·½Ê½ÓÐËùÇø±ð£º
Function.prototype.apply(thisArg,argArray);
Function.prototype.call(thisArg[,arg1[,arg2…]]);
´Óº¯ÊýÔ­ÐÍ¿ÉÒÔ¿´µ½£¬µÚÒ»¸ö²ÎÊý¶¼±»È¡ÃûΪthisArg£¬¼´ËùÓк¯ÊýÄÚ²¿µ ......

javascript Ö® Closure

http://javascript.crockford.com/private.html
function a() {
var i = 0;
function b() {
alert(++i);
}
return b;
}
var c = a();
c();
 
µ±ÔÚº¯ÊýbÖзÃÎÊÒ»¸ö±äÁ¿µÄʱºò£¬ËÑË÷˳ÐòÊÇ£º
ÏÈËÑË÷×ÔÉíµÄ»î¶¯¶ÔÏó£¬Èç¹û´æÔÚÔò·µ»Ø£¬Èç¹û²»´æÔÚ½«¼ÌÐøËÑË÷º¯ÊýaµÄ»î¶¯¶ÔÏó£¬ÒÀ ......

javascript Ö® prototype

function MyObject1(formalParameter){
    alert("MyObject1");    
    this.testNumber = formalParameter;
    //1
    this.toString= function(){
       alert("MyObject1:"+this.testNumber);
   &nbs ......

javascriptµÄ±ÊÊÔÌâÄ¿£¨¹²17µÀ£©¸½²Î¿¼´ð°¸

Éϴβ¿ÃÅÕÐÆ¸ÐèÒªwebǰ̨¼¼Êõ±ÊÊÔÌâÄ¿£¬ÎÒÔÚÍøÉÏËÑË÷һϣ¬»¹ÕæÕÒ²»µ½Ê²Ã´¡£ÓÚÊÇ×Ô¼º±àÁ˼¸µÀ¡£  
  ÕÐÆ¸½áÊøÁË£¬ÌâÄ¿¹À¼ÆÃ»ÓÃÁË¡£ÕâÀ﹫²¼³öÀ´£¬¶Ôjs¸ÐÐËȤµÄÐÂÊÖ¿ÉÒÔ×ö×ö¿´£¬»òÐíÓаïÖúŶ¡£  
  ´ð°¸¾Í²»¹«²¼ÁË£¬×Ô¼ºÒ»ÊÔ¾ÍÖªµÀÁË¡£  
   
  Ò»¡¢µ¥Ñ¡Ìâ  
  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ