How to disable right click and inspect element using javascript

What is Inspect Element ?

Inspect element is browser tool that lets user view and edit HTML and CSS code of web pages. However any edits or changes of HTML and CSS code user make will only appear on user personal screen, and changes live until you exit out. It's meaning you are not making any permanent changes to a website, so you are simply able to adjust it for the time being.

How to open inspect element ?

if you want to open inspect element then right click on webpage select last Inspect option also you use shortct key Ctrl + Shift and F12.

Howe to disable inspect element ?

if we not want to show inspect element or user not changes your HTML and CSS code then we can disable inspect element. i give you below code, you just copy and paste in webproject.


<html>
<head>
<h1 align="center">Disable Inspect Element</h1> 
</head>

<body oncontextmenu="return false;">

</body>
<script>
document.onkeydown = function(e) {
if(event.keyCode == 123) {
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;
}
}
</script>

<script>

</script>
</html>

Post a Comment (0)
Previous Post Next Post