开发者

event.preventDefault not working in mozilla

开发者 https://www.devze.com 2023-01-01 12:20 出处:网络
its wrking in ie but not in mozilla wats the alternate function preventBackspace(e) { var evt = e || window.event;

its wrking in ie but not in mozilla wats the alternate

  function preventBackspace(e) {

          var evt = e || window.event;
         // alert(evt);
          if (evt) {
              var keyCode = evt.charCode || evt.keyCode;
             // alert(keyCode);
              if (keyCode === 8) {
                if (evt.preventDefault) {
            evt.preventDefault();
                 } else {
                      evt.returnValue = false;
                 }
开发者_如何学JAVA              }
          }
      }

infact evt.returnvalue=false is not wrking in mozilla


I did a simple test (jsfiddle), and your function does work in Firefox. As expected, it never executes the non-standard returnValue part.

0

精彩评论

暂无评论...
验证码 换一张
取 消