I’m attempting to deactivate inspect on my server or website so that others can’t view my code and other reasons; I’m sorry if this seems too insecure, but if there’s a method, please tell/show me… I’ve been researching and have discovered some solutions, but I’ve tried and failed. Here is the code for what I attempted.
_document.js:
<Html onContextMenu={false}>
<Head>
{...}
</Head>
<body onContextMenu="false">
{...}
<Script>
{`document.addEventListener('keydown', function() {
if (event.keyCode == 123) {
alert("You Can not Do This!");
return false;
} else if (event.ctrlKey && event.shiftKey && event.keyCode == 73) {
alert("You Can not Do This!");
event.preventDefault();
return false;
} else if (event.ctrlKey && event.keyCode == 85) {
alert("You Can not Do This!");
return false;
}
}, false);
if (document.addEventListener) {
document.addEventListener('contextmenu', function(e) {
alert("You Can not Do This!");
e.preventDefault();
}, false);
} else {
document.attachEvent('oncontextmenu', function() {
alert("You Can not Do This!");
window.event.returnValue = false;
});
}
`}
</Script>
</body>
</Html>
All of the necessary imports are also present… I appreciate your assistance!
>Solution :
No, there’s no way to do that.
There might be some workarounds like blocking right click for example, but in general, source code of the webpage/website isn’t something you can protect against copying/stealing because that’s how Web works.
Whoever wants to see your source code might simply get it even without browser, if needed.