这也是转载的,让BackSpace按键不可作为退回使用,在textbox中设置readonly时,将退回禁用。
<script type="text/javascript"> //--设置backspace后退按键不可用(如果将textbox设置readonly,按键backspace会重复textbox的内容) document.onkeydown = check; 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>