现在的位置: 首页 > 综合 > 正文

如何实现ie禁止返回功能和禁止用户用back space键返回页面(未测试)

2012年08月11日 ⁄ 综合 ⁄ 共 815字 ⁄ 字号 评论关闭

function   setBSkey()   {  
  var   blnEevntCancel   =   false   ;  
   
          if   (window.event   &&   window.event.altKey   &&   (window.event.keyCode   ==   8   ||   window.event.keyCode   ==   37   ||   window.event.keyCode   ==   39   ))   {  
                  blnEevntCancel   =   true   ;  
          }  
  if   (   window.event.keyCode   ==   8   )   {  
  if   (window.event.srcElement.tagName.toUpperCase()   ==   "TEXTAREA")   {  
  if   (   window.event.srcElement.readOnly   ==   true   )   {  
                  blnEevntCancel   =   true   ;  
  }  
  }  
else   if   (window.event.srcElement.tagName.toUpperCase()   ==   "INPUT"   &&   event.srcElement.type.toUpperCase()   ==   'TEXT')       {  
  if   (   window.event.srcElement.readOnly   ==   true   )   {  
                  blnEevntCancel   =   true   ;  
  }  
  }   else   {  
                  blnEevntCancel   =   true   ;  
  }  
  }  
  if   (blnEevntCancel   ==   true   )   {  
  window.event.cancelBubble   =   true;  
          window.event.returnValue   =   false;  
          return   false;  
  }  
  }

抱歉!评论已关闭.