There are plenty of scripts available on the net, the one proposed by @mellowsoon is one of them.
However remember that it does not make text selection impossible, it just makes it difficult. Text selection can be "re-enabled" by the user by just disabling javascript or from the source by page.
Also such not selectable text is not very usable and may leave users frustrated.
If you are concerned with someone copying your content without your permission, use appropriate licenses and copyright, rather than such techniques (or use technologies like flash if applicable, but even here there are OCR techniques that can help copying text)
发布评论
评论(2)
您可以使用 jQuery 轻松完成。检查这个演示源,例如:
有一个来自 jquery 论坛的帖子,解释了
disableSelection
的情况。看起来它已经“无证”很长时间了。You can do it easily with jQuery. Check this demo sources, for example:
There's a post from jquery forum explaining the situation around
disableSelection
. Looks like it's 'undocumented' for a long time already.网上有很多可用的脚本,@mellowsoon 提出的脚本就是其中之一。
但请记住,它并不会使文本选择变得不可能,而只是使其变得困难。用户只需禁用 javascript 或从页面源即可“重新启用”文本选择。
此外,这种不可选择的文本不是很有用,并且可能会让用户感到沮丧。
如果您担心有人未经您的许可复制您的内容,请使用适当的许可证和版权,而不是此类技术(或使用 Flash 等技术(如果适用),但即使在这里,也有 OCR 技术可以帮助复制文本)
There are plenty of scripts available on the net, the one proposed by @mellowsoon is one of them.
However remember that it does not make text selection impossible, it just makes it difficult. Text selection can be "re-enabled" by the user by just disabling javascript or from the source by page.
Also such not selectable text is not very usable and may leave users frustrated.
If you are concerned with someone copying your content without your permission, use appropriate licenses and copyright, rather than such techniques (or use technologies like flash if applicable, but even here there are OCR techniques that can help copying text)