Skip to content

Instantly share code, notes, and snippets.

@haroldao
Created January 16, 2021 20:19
Show Gist options
  • Save haroldao/46ac5de82d0192fd654fd9e84055e347 to your computer and use it in GitHub Desktop.
Save haroldao/46ac5de82d0192fd654fd9e84055e347 to your computer and use it in GitHub Desktop.
<!-- Disable keyboard keys -->
<script>
document.onkeydown = function(e) {
return false;
}
</script>
<!-- Disable images drag -->
<script>
window.ondragstart = function() {
return false;
}
</script>
<!-- Disable right click -->
<script>
var message="Function Disabled!";
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown = clickIE4;
}
document.oncontextmenu = new Function("return false")
</script>
<!-- Disable text selection -->
<script>
onselectstart = (e) => {e.preventDefault()}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment