window.onload=function(){
 if (document.all){
 alert(document.all);
 window.document.onclick= new Function("return onClick(event);");
  }else{
 window.document.body.setAttribute("onclick","return onClick(event);")
 }}
我想要的效果有了,可是页面上的所以连接都失效了。请问该如何改写这段js

解决方案 »

  1.   

    function onClick(event){
    //...your code
    if(event.srcElement.tagName=='a')return true;
    //...your return
    }
      

  2.   

    window.onload=function(){ 
    if (document.all){ 
    alert(document.all); 
    window.document.onclick= new Function("if(event.srcElement.tagName=='A'){event.srcElement.click();}else{return onClick(event);}");//判断是否是超连接 
      }else{ 
    window.document.body.setAttribute("onclick","return onClick(event);") 
    } }
      

  3.   

    2L的办法是对的.
    else里会使a标签无效吗?没有试过, 如果发生也参照楼上代码加以修改就可以了