Home > Web Front-end > JS Tutorial > body text

Javascript disables keyboard function keys and makes right-click and other keys invalid_javascript tips

WBOY
Release: 2016-05-16 17:20:36
Original
1493 people have browsed it
Copy code The code is as follows:



The red display above can be inserted into the web page to invalidate the right mouse click
onselectstart="return false" prohibits selection, ondragstart="return false" prohibits drag and drop, oncopy=document.selection.empty () Copying prohibited.

Disable saving: , placed in the head.

Disable pasting:

Turn off input method:

Disable the right mouse button:
function document.oncontextmenu(){event.returnValue=false;}

Disable F1 help:
function window.onhelp(){return false}

Block other keys
Copy code The code is as follows:

function document.onkeydown()
{
if ((window.event.altKey)&&
((window.event.keyCode==37)|| //Shield Alt arrow key←
(window.event.keyCode= =39))) //Block the Alt direction key→
{
alert("You are not allowed to use the ALT direction key to move forward or backward on the web!");
event.returnValue=false;
}
/* Note: This is not really shielding the Alt direction key.
Because when the Alt direction key pops up a warning box, hold down the Alt key.
Click the warning box with the mouse. This shielding method It fails. In the future,
if any expert has a real way to block the Alt key, please let me know. */
if ((event.keyCode==8) || //Shield the backspace delete key
(event.keyCode==116)|| //Shield the F5 refresh key
(event.ctrlKey && event.keyCode==82)){ //Ctrl R
event.keyCode=0;
event.returnValue=false;
}
if (event.keyCode==122){event .keyCode=0;event.returnValue=false;} //Shield F11
if (event.ctrlKey && event.keyCode==78) event.returnValue=false; //Shield Ctrl n
if (event. shiftKey && event.keyCode==121)event.returnValue=false; //Shield shift F10
if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
window.event .returnValue = false; //Shield shift and left mouse button to open a new web page
if ((window.event.altKey)&&(window.event.keyCode==115)) //Shield Alt F4
{
window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
return false;
}
}

Block printing:
Copy code The code is as follows:


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!