I want to disable my webpage source code and inspect element bar. And I did it with this script. But if I wrote " view-source: "
before my url the source code will be shown. How can I fix this? Is there any possibility to hide source code? Good answers must be appreciated
<script>
document.onkeydown = function(e) {
if(e.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;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)){
return false;
}
}
</script>
There is no way to hide the JS code. JS-Scripts are running inside your Browser. So the Browser must know the JS-Scripts. And if the Browser know it, the user can have a look at them. You could only try to compress them, to avoid to easy reading by user.
Use https://jscompress.com/ if you have a static JS-Script
There is no way to hide source code & inspect element, but all you can do is disable
the the right click
of mouse button using
function disableclick(event){
if(event.button==2){ // this value is 3 for some othe browser
// Rest of code
return false;
}
}
document.body.onclick = disableclick()
Also not that you need to disable F12
key since pressing F12
open the developers console, which is actually bypass right click event
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With