jquery – disable right click

Disable the mouse right click as often used with websites who want to add some low level security. To Solve the purpose we just need to bind the contextmenu event.

 
$(document).ready(function(){
    $(document).bind("contextmenu",function(e){
        return false;
    });
});

Disable right click using javascript:

<script type=”text/javascript”>
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>

Share this nice post:

2 thoughts on “jquery – disable right click

  1. Fine way of describing, and good paragraph to obtain data concerning my presentation subject matter,
    which i am going to convey in academy.

  2. It’s remarkable in favour of me to have a site, which is useful in my experience. thanks admin

Comments are closed.