我已经添加代码,为什么不起作用,已试过多种浏览器,都没有用。是还需要在什么位置加代码吗?
<script type="text/javascript" language="javascript"> document.onkeydown = check; // document.onkeypress = check; document.onkeydown = function check(e) { var code; if (!e) var e = window.event; if (e.keyCode) code = e.keyCode; else if (e.which) code = e.which; if (((event.keyCode == 8) && //BackSpace ((event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password") || event.srcElement.readOnly == true)) || ((event.ctrlKey) && ((event.keyCode == 78) || (event.keyCode == 82))) || //CtrlN,CtrlR (event.keyCode == 116)) { //F5 event.keyCode = 0; event.returnValue = false; } return true; } </script>
//禁止后退键 作用于Firefox、Opera document.onkeypress = banBackSpace; //禁止后退键 作用于IE、Chrome document.onkeydown = banBackSpace;