A piece of JavaScript to achieve a ban a user opens a console, right mouse button to view the source code

For some reason many users do not want to be seen or to find information related to the source file address and other conventional techniques is shielded the right mouse button and the F12 key;

The Internet to find a lot of similar code is invalid, there is no enabled today to find the relevant code from a blog's source code and found very good with sharing out;

Left more than you need

<script type='text/javascript'> 
    window.oncontextmenu=function(){return false;} 
    window.onkeydown = window.onkeyup = window.onkeypress = function () { 
    window.event.returnValue = false; 
        return false; 
    } 
    var h = window.innerHeight,w=window.innerWidth; 
    window.onresize = function () { 
        if (h!= window.innerHeight||w!=window.innerWidth){ 
            window.close(); 
            window.location = "about:blank"; 
        } 
    } 
</script> 

It should be noted that because the code is JavaScript, it means that if the user's browser to disable JavaScript, the section of the code will fail.

Guess you like

Origin www.cnblogs.com/shenjingwa/p/11404955.html