防止网页图像被盗取
我一直在四处寻找是否存在一种好方法来阻止观看者使用右键单击选项下载我上传到我的网站的图像。 我知道人们可以查看页面源中的图像网址,并且想知道您是否建议通过禁用保存图像选项来防止它们被获取的方法。
I've been looking around to see if there exists a good way to prevent viewers from using their right click options to download images that I upload to my website.
I know that people can look at the image url in the page source, and was wondering if you suggest a way to prevent them being taken, by disabling the save image option.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是一个无法解决的问题。
只要您确实希望人们看到图像,您就无法阻止他们通过多种方法(例如屏幕截图)保存图像。您可能想到的所有措施都只会惹恼您的用户,而不会真正阻止他们做他们想做的事情。还要考虑到观看这些图像的人会对它们感兴趣(否则他们一开始就不会观看它们),因此我们已经有动机让他们保留副本。
可靠地防止人们保存图像的唯一方法是首先永远不要让他们将图像复制到自己的计算机上(请记住:在另一台计算机上显示某些内容总是需要制作副本)。
一种解决方案可能是邀请人们进入一个可以在您控制的屏幕上查看图像的地方,并且不允许他们拍摄任何照片。想象一下现代电影院,配备夜视仪的保安人员会监视观众,并拉出那些可能正在操作任何摄像机之类设备的人。
This is an unsolvable problem.
As long as you actually want people to see the images, you cannot prevent them from saving them via a number of methods (e.g. screenshots). All measures you might think of will just annoy your users, without actually preventing them from doing what they want anyway. Also consider that the people watching those images will have some interest in them (otherwise they would not watch them in the first place), so there we already have a motive for them to keep a copy.
The only way to reliably prevent people from saving the images is to never let them copy them onto their computers in the first place (and remember: showing something on another computer always entails making a copy).
One solution could be to invite people into a place where they can view the image on a screen which you control, and not let them take any pictures. Think of modern cinemas where security people with night sights watch the spectators and pull out those who might have been handling any camera like device.
如果您想让它变得更加困难,请不要使用 IMG 标签。相反,使用具有“background-image”属性的 CSS 来定义图像。为了让它变得更加棘手,请在运行时使用 JavaScript 定义该属性,该属性是使用 base64 编码放置在页面上的。
If you want to make it even more difficult, do not use an IMG tag. Instead, define the image using CSS with the property 'background-image'. To make it even more tricky, define that property at runtime using JavaScript that was placed on the page using base64 encoding.
您可以尝试这个...
这将禁止上下文(单击鼠标右键)菜单的操作...
不过,如果用户知道他们在做什么,他们就可以解决这个问题。
You can try this...
This will disallow the operation of the context (right mouse button click) menu...
If a user knows what they're doing they can get around this, though.
我建议不要这样做。这很烦人,而且你实际上并没有保护自己。
如果您必须这样做,jQuery 可以非常轻松地禁用右键单击菜单:
I suggest not doing this. It's annoying and you're not actually protecting yourself.
If you must, jQuery makes it pretty easy to disable the right click menu:
只要把你的照片弄得丑陋就没有人愿意拍了。
说实话,你担心什么?
Just make your images so ugly no one would want to take them.
Seriously, what are you worried about?
如果您使用 Microsoft Ajax Seadragon Deep Zoom 查看器来查看图像,那么您可以将图像呈现为大量重叠的图块 - 粘在一起确实很痛苦,难度取决于图像大小,但对于高分辨率图像,它会产生“打印屏幕”对于那些想偷东西的人来说,这是唯一的选择。
顺便说一句,上下文菜单在 div 上比在图像上效果更好(东西是气泡),并且您不必通过不单击整个文档来冒犯人们。
按类执行此操作,例如使用 Prototype:
If you use the Microsoft Ajax Seadragon Deep Zoom viewer for you images then you can present your images as lots of overlapping tiles - a real pain to stick back together, difficulty depends on images size, but for hi-resolution images it makes 'printscreen' the only option for those wanting to steal stuff.
Incidentally the contextmenu thing works on divs better than images (things bubble) and you don't have to offend people by doing no click on the whole document.
To do it by class, e.g. with Prototype: