Home > Web Front-end > JS Tutorial > JavaScript implementation prohibits right-clicking and F12 to view source code_javascript skills

JavaScript implementation prohibits right-clicking and F12 to view source code_javascript skills

WBOY
Release: 2016-05-16 16:24:16
Original
1972 people have browsed it

The function is very simple and the code is also very concise. There will be no more nonsense here. I will provide the source code directly and friends who need it can take it away directly.

Copy code The code is as follows:

function click(e) {
if (document.all) {
if (event.button==2||event.button==3) { alert("Welcome to Humble House. If you need any help, please contact the webmaster! Thank you for your cooperation!!!");
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")

document.onkeydown =document.onkeyup = document.onkeypress=function(){
if(window.event.keyCode == 123) {
window.event.returnValue=false;
return(false);
}
}
<--123——112 is the code number of F1-F12-->

This is so that others don’t look at your code. For those who don’t understand, if you are an experienced person, you can’t prevent it!

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