How to block inspect element on website
×


How to disable inspect element

46066

Sometimes you want to disable inspect elements from your website to secure it. There are many ways to inspect the code of the 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 it 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>

Inspect Element is one of the helpful highlights that can show, alter, and even change the HTML code taken from the source site but it can also be harmful to a site's security. So, it becomes very important to disable it.

If you want to remove the right click too from your website. Then, click on the below topics.


Related Topic:

How do I disable right click on my web page
How to disable right click on the webpage using JavaScript


Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments