如何禁用右键单击一个特定图像上的保存 [英] How to disable right-click save on one specific image only

查看:115
本文介绍了如何禁用右键单击一个特定图像上的保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运营一个亚洲电子商务网站,用户可以在其中发布产品图片。有没有办法在页面上仅禁用1个特定图像的右键单击?

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 - 我完全理解为什么不禁用右键单击的可用性原因,但亚洲的版权和图像盗窃是一个比北美国家。此外,对于卖家而言,这比实际保护内容更为安心。

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.

推荐答案

虽然它不符合W3C标准, oncontextmenu =return false;作为属性应该完全符合您的要求。

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

这篇关于如何禁用右键单击一个特定图像上的保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆