0

I have an image. When I left click on it, it should increase the value behind the image by 1. When I right click on it, it should decrease the value behind the image by 2.

The problem is, when I right click the image, it decreases the value correctly. However, Mozilla Firefox pops a window like "Copy this image, View this image" etc.

How can I prevent this?

Aristona
  • 8,611
  • 9
  • 54
  • 80
  • 3
    search a bit; http://stackoverflow.com/questions/737022/how-do-i-disable-right-click-on-my-web-page – mreq Jan 01 '12 at 20:36

1 Answers1

2

That is the context menu, a standard feature of Modern OS' and not specific to Firefox.

To disable the context menu for images, use:

$(document).on('contextmenu', 'img', function() { return false; });

via DevGrow, modified to use the jQuery 1.7+ .on() to attach the event handler.

Ansel Santosa
  • 8,224
  • 1
  • 28
  • 39