HTML页面禁用复制/粘贴 [英] HTML page disable copy/paste
问题描述
在HTML页面中,不允许用户复制文本,但同时我想为用户提供选择特定文本的选项(用于突出显示)。这意味着应该禁用 CTRL + C ,并且应该启用 CTRL + A 。
In a HTML page user should not be allowed to copy a text, but at the same time I want to give option for the user to select a particular text (for highlighting purpose). That means CTRL+C should be disabled and CTRL+A should be enabled.
谁能告诉我怎么做?
推荐答案
你不能阻止人们复制文字从你的页面。如果您正在尝试满足要求,这可能对您有用:
You cannot prevent people from copying text from your page. If you are trying to satisfy a "requirement" this may work for you:
<body oncopy="return false" oncut="return false" onpaste="return false">
如何使用javascript为Internet Explorer和Firefox浏览器禁用Ctrl C / V
更高级的方法:
如何使用JavaScript检测Ctrl + V,Ctrl + C?
编辑:我只是想强调一下禁用复制/粘贴很烦人,不会阻止复制,99%可能是一个坏主意。
I just want to emphasise that disabling copy/paste is annoying, won't prevent copying and is 99% likely a bad idea.
这篇关于HTML页面禁用复制/粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!