Click here to Skip to main content
15,035,600 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
How to disable the default context menu appears on right click of mouse?

For this i am catching mousedown event like-
$(.mydiv).mousedown(function (event) {
switch (event.which) {
case 1:alert("left click ");
break;
case 2:alert("right click ");
break;
case 3:
event.preventDefault();
$(this).trigger('click');
break;
default:
alert("strange mouse");
}
});
by doing this it works fine, but i don't want to show alert on mouse click(this is happening becoz of ($(this.trigger('click')) so if i remove this alert then again it is showing the default context menu.
Posted

1 solution

in your html:

HTML
<body oncontextmenu="return false;">
</body>


http://msdn.microsoft.com/en-us/library/ie/ms536914%28v=vs.85%29.aspx[^]

if you're using jquery:

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900