当前位置: 代码迷 >> JavaScript >> js-障蔽Backspace,输入内容不屏蔽
  详细解决方案

js-障蔽Backspace,输入内容不屏蔽

热度:139   发布时间:2012-10-15 09:45:24.0
js--屏蔽Backspace,输入内容不屏蔽

<script type="text/javascript">??
??? /*屏蔽Backspace,输入内容不屏蔽*/
??? function document.onkeydown()
??? {
??????? if(document.activeElement.type == "text")
??????? {
??????????? if ((event.keyCode==116)||??????????? //屏蔽 F5 刷新键
?????????? (event.ctrlKey && event.keyCode==82))//Ctrl + R
?????????? {
?????????????? event.keyCode=0;
?????????????? event.returnValue=false;
?????????? }
??????? }
?????? else
?????? {
?????????? if ((event.keyCode==8)?? ||???????????? //屏蔽退格删除键
?????????? (event.keyCode==116)||????????????????? //屏蔽 F5 刷新键
?????????? (event.ctrlKey && event.keyCode==82)){ //Ctrl + R
????????? event.keyCode=0;
????????? event.returnValue=false;
????????? }
??????? }
??? }
</script>