Click here to Skip to main content
15,034,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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("middle click ");
break;
case 3:
alert("right click");
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
Updated 4-May-12 0:10am
v2
Comments
Sandeep Mewara 4-May-12 9:35am
   
Why repost?

1 solution

Hi,

add this replacing your body tag
HTML
<body oncontextmenu="return false;"></body>

hope this will help you
   

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