This article mainly introduces the javascript code that disables right-click and F12 viewing source code. if you need code, you can refer to the function below. the code is also very simple. there is not much nonsense here, and the source code is provided directly, you need to take it directly.
The code is as follows:
Function click (e ){
If (document. all ){
If (event. button = 2 | event. button = 3) {alert ("Welcome to the cold 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 number of code for the F1-F12 -->
This is to prevent others from reading your code!