Home >Web Front-end >JS Tutorial >JS code that prohibits shortcut keys such as F5_Typical special effects

JS code that prohibits shortcut keys such as F5_Typical special effects

WBOY
WBOYOriginal
2016-05-16 19:17:561076browse

JS code to disable ctrl n and ctrl r and disable shift f10, disable the right or left mouse button and disable f5



<script> <BR>//禁止ctrl+n和 禁止ctrl+r和 禁止shift+f10 禁止鼠标右键or左右键 和禁止f5 <BR>var oLastBtn=0,bIsMenu=false <BR>if (window.Event) <BR>{ <BR>document.captureEvents(Event.MOUSEUP); <BR>} <br><br>function nocontextmenu() <BR>{ <BR>event.cancelBubble=true; <BR>event.returnValue=false; <BR>return false; <BR>} <br><br>function norightclick(e) <br><br>{ <BR>if(window.Event) <BR>{ <BR>if (e.which !=1) <BR>{ <BR>return false; <BR>} <BR>} <BR>else <BR>if(event.button!=1) <BR>{ <BR>event.cancelBubble=true; <BR>event.returnValue=false; <BR>return false; <BR>} <BR>} <br><br>document.oncontextmenu=nocontextmenu; <BR>document.onmousedown=norightclick; <br><br>function onKeyDown() <BR>{ <BR>if ((event.altKey)||((event.keyCode==8)&&(event.srcElement.type!="text"&&event.srcElement.type!="textarea"&&event.srcElement.type!="password"))||((event.ctrlKey)&&((event.keyCode==78)||(event.keyCode==82)))||(event.keyCode==116)) <BR>{ <BR>event.keyCode=0; <BR>event.returnValue=false; <BR>} <BR>} <BR></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn