遇到一个js阻止浏览器事件发生的问题,网上的解决办法如下 :
1.阻止浏览器的默认行为
JavaScript代码
//如果提供了事件对象,则这是一个非IE浏览器 
if ( e && e.preventDefault ) 
  //阻止默认浏览器动作(W3C) 
  e.preventDefault(); 
else
  //IE中阻止函数器默认动作的方式 
  window.event.returnValue = false; 
return false;
可是这些方法在IE7不管用啊,但是我又特别需要这个功能,在IE7怎么解决这个问题啊(阻止浏览器的事件),window.event.returnValue = false,这个方法只在IE6下面管用
分不够,再加,在线等,急

解决方案 »

  1.   


    var stopEvent=function(e){//阻止事件
    e = e||window.event;
    if(e.stopPropagation){e.stopPropagation();}else{e.cancelBubble = true;}//阻止冒泡
    if(e.preventDefault){e.preventDefault();}else{e.returnValue = false;}//阻止Event返回值
    }
      

  2.   

    请问一下,我在前台页面的onbeforeunload事件中调用了一个js方法validateFlow(),在这个js方法中,我要怎么写你说的那个方法
      

  3.   


    window.onbeforeunload=function(e) {
    stopEvent(e);
    }