First, you must know that your 'a' object does not define an onclick event, so you can not use "dispatchEvent" to fire the event.Second, you should code that://e.dispatchEvent(e);
o.dispatchEvent(e);

解决方案 »

  1.   

    谢谢了,还好看得懂一点,呵呵,第二个错误是我写错了。But,han can i define an onclick event at 'a',and use "dispatchEvent" to fire the event.
      

  2.   

    But,how can i define an onclick event at 'a',and use "dispatchEvent" to fire the event.
      

  3.   

    <a href="javascript:void(0)" onclick="aa()">thet it!</a>
      

  4.   

    Besides yigx007's way, you can use "addEventListener" to attach an event listener to an element, please refer to:http://developer.mozilla.org/en/docs/DOM:element.addEventListener
      

  5.   

    我的效果就是要"点击打开163"这个层,能够触发id 为a这个链接的click事件,进而打开id为a链接的页面
      

  6.   

    <a href="http://www.163.com"  id="a" target="_blank" ></a><span style="cursor:pointer" onclick="aa('a')">点击打开163</span>
    <script language=javascript>
    function aa(d_linka){var   o   =   document.getElementById(d_linka);   
      if(   document.all   &&   typeof(   document.all   )   ==   "object"   )   //IE   
      {   
      o.click();   
      }   
      else   
      {   
      var   e   =   document.createEvent('MouseEvents');   
      e.initEvent('click',true,true);   
      o.dispatchEvent(e);   
      }
    }
    </script>
      

  7.   

    hbhbhbhbhb1021,我的脚本就是这样的
      

  8.   

    不知道hbhbhbhbhb1021的在firefox下测试过没
    我测试了,还是不行的
    firefox版本是2.0
      

  9.   

    <a href="http://www.163.com"  id="a" target="_blank" onclick="window.open(this.uref, this.target)"></a>
      

  10.   

    用window.open在firefox底下是会被阻止弹出的。
    万不得已时不用