How to disable inspect element

by Lalita 07-Jun-19

0 89


Sometimes you want to disable inspect elements from your website to secure it. There are many ways to inspect the code of website or find the words in the code etc.

For Example: by right click, by pressing key F12, by ctrl+shift+i, by ctrl+f etc.

So to disable these keys or clicks, copy the below code and paste on your website page. Remember that it will only disable that page code where you have used this code.

<script>
/* To Disable Inspect Element */
$(document).bind("contextmenu",function(e) {
e.preventDefault();
});

$(document).keydown(function(e){
if(e.which === 123){
return false;
}
});
</script>
/* To Disable multiple Keys used with ctrl key & ctrl+shift key */
<script>
document.onkeydown = function(e) {
if(event.keyCode == 123) {
return false;
}
if(e.ctrlKey && e.keyCode == 'E'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'S'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'H'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'A'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'F'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'E'.charCodeAt(0)){
return false;
}
}
</script>


Share:


Comments

    No Comments Yet.

Leave a Reply