在Firefox中防止选择/复制到剪贴板 [英] Preventing Selection / Copy to Clipboard in Firefox

查看:153
本文介绍了在Firefox中防止选择/复制到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要阻止用户使用java脚本在浏览器Mozilla Firefox中选择文本(全选或选择一部分文本)。
我已经使用Internet Explorer完成了这项工作,但似乎无法与Mozilla兼容。



任何提示?网址是什么?样本?



TIA。

编辑:

其实这个荒谬的问题是我们的客户要求的。是的,我们已经向他们解释说,还有其他方法可以获得文本。但他们回答说,他们知道这一点,他们只是想防止业余用户这样做。

我已经做了一些Google搜索,并找到类似的问题,解决方案 here

解决方案

没有办法充分保护您发布的内容,缺乏对于网站不够普及的DRM方案。但是为了防止简单的复制和粘贴,有几种方法,每个方法都会让用户非常烦恼。



简单的方法是将文本覆盖元素,如 DIV ,使用CSS定位。这意味着当用户尝试点击 DIV 选择文本时,将不会有文本可供选择。应该在任何支持CSS的浏览器中工作,而在不支持浏览器的浏览器中,它可能完全不可见。点击页面并点击 CTRL + A (或其他一些快捷键)可能会选择文本,并且可能无法阻止所有的键盘和鼠标事件得到文本。但是这个 DIV lid方法至少是不显眼的,并且容易推广。但是,通过查看HTML源代码,这是很平常的。它通过关闭CSS(在Firefox中很容易做到,并且许多Firefox用户已经足够复杂)来简单地击败了。

更强大的方法是使用普通的图像文件或类似PDF的东西将文本呈现为图形。但是图形可以被OCR化。这里有免费的工具。



最后,你可以把你的文本放在一个Flash或者Java applet中,这个applet可以从服务器上下载文本。有人可能会窃取你的小程序,但由于同源安全策略,难以使其与您的网络服务器通话(注意:这也可以解决)。这种方法并不比PDF方法好得多,只不过它使抓取整个文档变得困难,因为applet一次只能显示文档的一部分。要使用OCR来击败这个攻击者,必须采取屏幕截图。或者他们可以逆向工程你的小程序,并创建一个新的小程序(甚至是一个普通的程序),从服务器上下载所有的内容。



所有这些方法只是最基本的用法,我怀疑你会发现他们根本没有帮助。你可能会获得更多的投资回报,建立有用的功能,而不是这个。


I need to prevent user from selecting text (select all or select a portion of text) in the browser Mozilla Firefox, using java script. I have done this using Internet Explorer, but it seems doesn't work with Mozilla.

Any hints? URL? Sample?

TIA.

EDIT:

Actually, this ridiculous problem was requested by our client. And yes, we have explained them that there are thousand other ways to get the text. But they answer that they know about that, they just want to prevent for amateur user to do that.

I have done some googling and find similar problem with the solution here.

解决方案

There is no way to fully protect content you publish, short of DRM schemes which are not widespread enough to be useful for a website. But to prevent simple copy-and-paste there are several approaches, each of which is very annoying to your users.

A simple way would be to cover the text with another element, such as a DIV, using CSS positioning. This would mean that when the user tries to click on the DIV to select the text there would be no text to select. Should work in any browser that supports CSS and in browsers that don't it will probably be completely invisible. Clicking on the page and hitting CTRL+A (or some other shortcut key) may select the text anyway, and it may be impossible to block all key and mouse events that can get at the text. But this DIV "lid" approach is at least unobtrusive and easy to generalize. However, this is trivially defeated by looking at the HTML source. It is less trivially defeated by turning off CSS (easy to do in Firefox, and many Firefox users are sophisticated enough to do it).

A more robust approach would be to render the text as a graphic, either using a regular image file or something like a PDF. However graphics can be OCR'ed. There are free tools for this.

Finally you could put your text in a Flash or Java applet, which would download the text from the server. Someone could steal your applet but would have difficulty making it talk to your webserver due to the same-origin security policy (note: this can also be worked around). This approach is not that much better than the PDF approach except that it makes it harder to grab entire documents, because the applet will only display a portion of the document at a time. To defeat this using OCR the attacker has to take screen-captures. Or they could reverse-engineer your applet and make a new applet (or even a regular program) which downloads all the content from your server.

All those approaches are only of the most basic use and I suspect you'll find that they don't help at all. You'd probably get more return on investment building useful features rather than this.

这篇关于在Firefox中防止选择/复制到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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