先提供參考網址 http://people-k.blogspot.tw/2008/05/javascript-backspace.html http://followmeyo.blogspot.tw/2013/12/javascript-backspace.html 附上我修改過的 IE、FireFox、Chrome都可以用
<script language="JavaScript">
if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
document.onkeydown = check;
} else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
document.onkeypress = check;
} else {
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 (code == 8) {
code = 0;
return false;
}
return true;
}
</script>
沒有留言:
張貼留言