Skip to content

Instantly share code, notes, and snippets.

@onuproy
Created July 21, 2019 04:20
Show Gist options
  • Save onuproy/e57d7a63622417a7effd79e2e4fea4f8 to your computer and use it in GitHub Desktop.
Save onuproy/e57d7a63622417a7effd79e2e4fea4f8 to your computer and use it in GitHub Desktop.
Disable mouse right-click
<script>
var isNS = (navigator.appName == "Netscape") ? 1 : 0;
if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
function mischandler(){
return false;
}
function mousehandler(e){
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if((eventbutton==2)||(eventbutton==3)) return false;
}
document.oncontextmenu = mischandler;
document.onmousedown = mousehandler;
document.onmouseup = mousehandler;
</script>
@onuproy
Copy link
Author

onuproy commented Jul 21, 2019

It's code very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment