<div id="t">23423423423423423</div><script>
t.attachEvent("onclick", function(e){
alert(e)
alert(event)
alert(e.clientX==event.clientX)
alert(e==event)
});
</script>ie测试
以前一直没发现attachEvent的函数第一个参数会是event
不知哪里有相关说明呢
而用e==event又会是false为什么呢

解决方案 »

  1.   

    attachEvent和click两个函数造成的吧,已经不是一个函数了,所以就不同了
      

  2.   


    但一般ie用的是window.event这样的全局变量
    应该同一个才对啊
      

  3.   

    好象是与attachEvent无关
    单独写在事件触发的函数也是false  原因不明
    <div id='ss' onclick="xx(window.event)">sasdfsdf</div>
    <script>
    alert(window.event==window.event);  //true
    (function(){
    alert(window.event==window.event);//true
    })();

    function xx(e){
    alert(e==window.event);//false
    alert(window.event==window.event);//false
    }</script>
      

  4.   

    <div id='ss' onclick="xx()">sasdfsdf</div>
    <script>
    function xx(){
        var e=event
    alert(e==e);//true
    alert(e==event);//false
    }
    xx()
    </script>看来在事件函数里每次重新获取的event都互不相等的
    原因还是不清楚
      

  5.   

    ie8:<div id='ss' onclick="xx()">sasdfsdf</div>
    <script>
    function xx(){
    var e=event
    alert(e==e);//true
    alert(e==event);//true
    }
    xx()
    </script>
      

  6.   

    简单测试了一下: <BODY onclick="a(event)">
     <script>
      function a(ev){
       for(var b in ev){

    if(ev[b]!=event[b]){
    alert(b); //output "boundElements";

    }
       }
       for(var b in event){
     if(event[b]!=event[b]){
    alert(b);  //output "boundElements"
     }
       }
      }
     </script>发现event对象中有一个属性boundElements都不同.其它都是一模一样的.
    cloudgamer可以再研究下这个属性
      

  7.   


    有属性不同不奇怪
    但一般理解是window.event是一个对象
    即使修改了其中一个属性应该还是相等的
    但目前看来每次获取的event都不是同一个对象了
    (猜测)如果是事件里每次获取的event都是重新生成的那就能解析了
      

  8.   


    我也觉得触发事件时,event对像每次都重新创建了一个...
      

  9.   

    <div id='ss' onmouseup="xx()">sasdfsdf</div>
    <script>
    function xx(){
    event.xx=1
    alert(event.xx);//undefined
    }
    </script>
      

  10.   


    呵呵 4#桃子 举得例子都不太恰当.
    alert(window.event==window.event);  //true
    (function(){
    alert(window.event==window.event);//true
    })();
        
    window.event在没有事件触发的情况下 都是null
    null == null 说明不了问题了..
    //----------------------------------------------
    <div id='ss' onmouseup="xx()">sasdfsdf</div>
    <script>
    function xx(){
    event.xx=1
    alert(event.xx);//undefined
    }
    我觉得这个例子确实就能说明问题了. 估计每次操作event都是重新copy的 问了防止互相污染吧.
    但这样效率是不是要很低了? 待证据...
    </script>
      

  11.   

    这个当然不奇怪了,看看您的代码,attachEvent("onclick",function(e){...}),这里面的e是[object MouseEvent],而你代码里的event是[window.event],二者不一样,可以说是父子关系吧
      

  12.   

    如果是重新生成的话
    那以后用window.event看来还得用个变量保存一下了
      

  13.   

    每次获取都进行一次深度拷贝。所以对象是不同的。可能是为了提高window.event的实时的处理能力吧。
    我猜的。
      

  14.   

    能问一下在Firefox下的情况吗?