简体   繁体   English

复制粘贴防止JS代码没有禁用输入(搜索字段)元素?

[英]Copy-Paste prevent JS code without disable input (search field) element?

I used this code to prevent copy/paste function on my site, but in firefox it has disabled the search field too. 我使用此代码来防止在我的网站上执行复制/粘贴功能,但是在firefox中,它也禁用了搜索字段。 :( :(

Is there any way to do this that excludes the input field in this code? 有什么办法可以排除此代码中的输入字段?

 <script type="text/JavaScript"> function killCopy(e) { return false; } function reEnable(){ return true; } document.onselectstart = new Function("return false"); if (window.sidebar) { document.onmousedown = killCopy; document.onclick = reEnable; } </script> 

HTML file HTML文件

<input id="email" name="email">

jquery code jQuery代码

$('#email').bind('copy paste', function (e) {
        e.preventDefault();
    });

Or 要么

Don't do it. 不要这样 Don't mess with the user's browser. 不要搞乱用户的浏览器。 By Copy + Pasting into an E-Mail confirmation field, the user accepts responsibility over what they type. 通过将“复制+粘贴”到“电子邮件”确认字段中,用户将对其键入的内容承担责任。 If they are dumb enough to copy + paste a faulty address (it has happened to me) then it's their own damn fault. 如果他们愚蠢到足以复制并粘贴错误的地址(发生在我身上),那是他们自己的错。

If you want to make sure that the E-Mail confirmation works out, have the user check their E-Mail while your site waits ("Please open your webmail program in a new window"). 如果要确保可以完成电子邮件确认,请让用户在站点等待时检查其电子邮件(“请在新窗口中打开Webmail程序”)。 Show the E-Mail address in big fat letters ("The confirmation E-Mail was sent to.... made an error? CLick here to change). 用大写字母显示电子邮件地址(“确认电子邮件已发送至...。出错了?请单击此处进行更改)。

Even better, if you can, let the user have some kind of limited access without confirming. 如果可以的话,甚至更好的做法是,让用户拥有某种受限的访问权限而无需确认。 That way, they can log in straight away and you improve your chances to keep in touch with the visitor even if the confirmation mail is blocked due to other reasons (eg spam filters). 这样,他们可以立即登录,即使确认邮件由于其他原因(例如垃圾邮件过滤器)而被阻止,您也可以提高与访客保持联系的机会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VUE 和 JS:在 contenteditable 元素上禁用除复制粘贴 (CTRL + C) 之外的所有键盘事件 - VUE & JS: Disable all keyboard events except copy-paste (CTRL + C) on contenteditable element 如何防止用户在复制粘贴操作时立即将带有无效字符的文本复制粘贴到输入文本字段中? - How to prevent user from copy-pasting text with invalid characters into input text field immediately on copy-paste action? 从Internet复制粘贴图像到输入字段 - Copy-Paste image from internet to input field 从文本编辑器禁用复制粘贴 - Disable Copy-Paste from the Text Editor 防止将特定的用户控件元素放置在复制粘贴剪贴板上 - Prevent specific user control element from being put on the copy-paste clipboard 高效的jQuery / JS-避免一次又一次地复制粘贴相同的代码 - Efficient jQuery/JS - avoiding copy-paste the same code again & again javascript加载故障。 代码适用于手动复制粘贴,但不适用于JS - javascript load malfunction. Code works with Manual copy-paste, but not with JS 如何减少复制粘贴代码? 重构? - How can I reduce the copy-paste code? Refactor? 如何在 React js 的输入框中禁用复制粘贴 - How I can disable copy paste in an input box in react js 如何防止/禁用Tinymce中的复制和粘贴 - How to Prevent/disable copy and paste in Tinymce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM