Created
July 21, 2019 04:20
-
-
Save onuproy/e57d7a63622417a7effd79e2e4fea4f8 to your computer and use it in GitHub Desktop.
Disable mouse right-click
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's code very helpful!