防止在html输入字段中进行复制/粘贴. [英] Prevent copy/paste in a html input field.

查看:414
本文介绍了防止在html输入字段中进行复制/粘贴.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止用户在html输入字段中进行复制/粘贴操作?

How to prevent users'' copy/paste actions in a html input field?

推荐答案

尝试使用给出的解决方法
Try the fix given here[^]. Note that it only works for IE.


如果您通过Google搜索,可以找到成百上千个JavaScript.其中一些适用于某些浏览器,而其他则适用于其他浏览器.但是最终,您将提出一种适用于几乎所有浏览器的解决方案.

但这不是重点.所有这些实现都是使用JavaScript完成的.如果限制复制/粘贴的目的是保护您网站的内容,那么我说这是一种approach脚的方法.首先,用户可以禁用JavaScript.其次,他可以查看源代码.最重要的是,由于所有数据已经​​发送到客户端,因此,如果用户确实需要,大约有五千万种方法可以恢复该数据.

因此,我的建议是,不要为如此小的结果而浪费您的精力.
You can find hundreds of JavaScripts to do this if you Googled. Some of them works for some browsers and others work in other browsers. But eventually you will come up with a solution that works on almost every browser.

But that''s not the point. All these implementations are done using JavaScript. If the intent of restricting copy/paste is to protect your site''s content, I say it''s a lame approach. Firstly, user can disable JavaScript. Secondly, he can view source. And above all, since all the data is sent to the client side already, there are about fifty million ways to recover that data if the user really needs them.

So my advice, do not waste your effort for so small a result.


在< input标记中(只需编写代码:oncopy ="return false" onpaste ="return false")
html不允许从输入字段复制或粘贴数据.
In <input tag (just write the code : oncopy="return false" onpaste="return false" )
html doesn''t allow to copy or paste data from the input field.


这篇关于防止在html输入字段中进行复制/粘贴.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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