为什么加上这段就可以用"this"(this.id)了呢?
还有,这句话什么意思呀? --> "var functionString = eventType + functionRef;"
事件类型加上函数名,好奇怪的语法呀!!!!
帮我解释解释吧,实在是不明白呀 !!!EventHelp.addEvent = function(target, eventType, functionRef){
    if (typeof target.addEventListener != "undefined") {
        target.addEventListener(eventType, functionRef, false);
    }else if (typeof target.attachEvent != "undefined") {
////////////////////////////这段我看不明白呢!!/////////////////////////////////
        var functionString = eventType + functionRef;
     target["e" + functionString] = functionRef;
     target[functionString] = function(event) {
       if(typeof event == "undefined"){event = window.event}; target["e" + functionString](event);
     };
     target.attachEvent("on" + eventType, target[functionString]);
/////////////////////////////////////////////////////////////////////////////
// level 0 DOM
    }else {
        eventType = "on" + eventType;
        if (typeof target[eventType] == "function") {
         var oldListener = target[eventType];
            target[eventType] = function() {
                oldListener();
                return functionRef();
            }
         }else {
            target[eventType] = functionRef;
         }
     }
 // return
    return true;
};<script>
function y() {
  alert(this.id); //"aa"
  alert(this.nodeName);  // "A"
}EventHelp.addLoad(function() {
   var obj = document.getElementById("aa");
   EventHelp.addEvent(obj, "mouseover", y);
});
</script><a href="huhiyb.html" id="aa">xfdf<span>vbcbcv</span>dfdf</a>

解决方案 »

  1.   

    EventHelp.addEvent(obj, "mouseover", y);
    这句话 就是调用y()
      

  2.   

    FF的addEventListener就不说了
    说说attachEvent吧也就是这段
    /////////////////////////////////////////////////////////////
            var functionString = eventType + functionRef;
            target["e" + functionString] = functionRef;
            target[functionString] = function(event) {
                  if(typeof event == "undefined"){event = window.event}; target["e" + functionString](event);
            };
            target.attachEvent("on" + eventType, target[functionString]);
    /////////////////////////////////////////////////////////////////////////////以EventHelp.addEvent(obj, "mouseover", y)为例
    在obj的DOM引用内创建一个名为emouseoverfunction y() {alert(this.id); alert(this.nodeName);}的属性
    其内容是y这个函数的引用对象
    而另一个是名为mouseoverfunction y() {alert(this.id); alert(this.nodeName);}的属性
    其内容是新建的函数,并且其函数执行前面一个属性的函数,传递event进去。整个过程相当于,对obj元素注册了onmouseover事件,事件最终执行的是y函数
      

  3.   

    呵呵,教你一个学习的方法:再你不明白他为什么这么定义的时候,你先alert出结果,看看得到的结果是什么,再从结果取追寻就知道他为什么要那么定义了