Disable right click menu on click
I am trying to build a minesweeper game with php and jquery. This means I
want the user to be able to right-click elements to mark areas as a
potential bomb or a questionmark. Now I have the right click event and the
code works, however if I don't alert anything I get the menu with inspect
element etc. I've tried throwing in some return false's but they haven't
helped. How can I stop the menu appearing on right-click?
$('.overlay').mousedown(function(event) {
switch (event.which) {
case 1:
//left click code
break;
case 3:
theID = event.target.id;
if ($('#'+theID).is(":visible") &&
$('.bomb_'+theID).css("visibility") == "hidden"
&& $('.mystery_'+theID).css("visibility") == "hidden"){
$('#'+theID).css("background", "none");
$('.bomb_'+theID).css("visibility", "visible");
alert("x");
}else if($('.bomb_'+theID).is(":visible")){
$('.bomb_'+theID).css("visibility", "hidden");
$('.mystery_'+theID).css("visibility", "visible");
alert("y");
}else{
$('.mystery_'+theID).css("visibility", "hidden");
$('#'+theID).css("background", "#fff");
alert("z");
}
break;
}
});
Have tried to add event.preventDefault(); under the mousedown function but
this doesn't change anything. Also tried it under case 3:.
No comments:
Post a Comment