Home  >  Article  >  Web Front-end  >  JavaScript shortcut key setting implementation code_javascript skills

JavaScript shortcut key setting implementation code_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:55:331336browse
Block Alt F4 and other shortcut keys:
Copy code The code is as follows:

<script> <br>function KeyDown(){ //Shield the right mouse button, Ctrl n, shift F10, F5 refresh, backspace key<br>//alert("ASCII code is: " event.keyCode); <br>if ((window.event.altKey)&& <br>((window.event.keyCode==37)|| //Shield Alt arrow key← <br>(window.event.keyCode==39))) { //Block the Alt direction key→ <br>alert("You are not allowed to use the ALT direction key to move forward or back on the web!"); <br>event.returnValue=false; <br>} <br>if ((event. keyCode==8) || //Shield the backspace delete key<br>(event.keyCode==116)|| //Shield the F5 refresh key<br>(event.keyCode==112)|| //Shield F1 Refresh key<br>(event.ctrlKey && event.keyCode==82)){ //Ctrl R <br>event.keyCode=0; <br>event.returnValue=false; <br>} <br>if ( (event.ctrlKey)&&(event.keyCode==78)) //Shield Ctrl n <br>event.returnValue=false; <br>if ((event.shiftKey)&&(event.keyCode==121)) / /Shield shift F10 <br>event.returnValue=false; <br>if (window.event.srcElement.tagName == "A" && window.event.shiftKey) <br>window.event.returnValue = false; // Block shift and use the left mouse button to open a new webpage<br>if ((window.event.altKey)&&(window.event.keyCode==115)){ //Shield Alt F4 <br>window.showModelessDialog("about: blank","","dialogWidth:1px;dialogheight:1px"); <br>return false;} <br>} <br>function Showhelp(){ <br>alert("Wrong!"); <br> return false; <br>} <br></script>

================================================== ===============
IE Javascript shortcut key operation
1. oncontextmenu="window.event.returnValue=false" will completely block the right mouse button
no
Can be used for Table
2. Cancel selection and prevent copying
3. onpaste="return false" does not allow pasting
4. oncopy="return false;" oncut="return false;" prevents copying
5. Replace the IE address bar with your own icon
6. Can display your icon in favorites
7. Turn off the input method
8. Always carry the frame

9. Prevent being framed

10.
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