justinl justinl - 11 days ago 5x
Javascript Question

How to disable right-click save on one specific image only

I'm running an Asian e-commerce site where users post images of their products. Is there a way to disable right click for only 1 specific image on the page?

E.g. When viewing a product, there is a large image, and then some thumbnails of the product. When trying to right click on the large image, I want to disable right click, but if they try to right click on the thumbnails, I don't want to have right click disabled.


ps - I fully understand the usability reasons why NOT to disable right-click, but copyright and image theft in Asia is a much larger problem than in North American countries. Plus, this is more for the seller peace-of-mind than actually protecting the content.


Although it's not W3C compliant, oncontextmenu="return false;" as an attribute should do exact what you want.