问题描述
我禁用了输入文字框:
<input type="text" name="name" disabled="disabled" />
在IE和Chrome中,您可以复制并粘贴该输入字段中填充的值,但在Firefox中不能。
In IE and in Chrome you can copy and paste the value populated in that input field but in Firefox you cannot.
Firefox不允许通过JavaScript进行剪贴板操作以获得有效的安全问题。
Firefox does not allow clipboard manipulation through JavaScript for valid security concerns.
有什么建议吗?有没有解决这个问题?
Any suggestion? Is there a work around this?
推荐答案
我不喜欢使用readonly =readonly, 曾经的。它通过tab buttonpress使场地可聚焦和可达,如果上帝禁止,用户在只读字段聚焦时点击退格键,那么大多数浏览器都会像用户点击后退按钮一样对待它以前浏览的页面。 不 当您填写大型表单时,您希望看到的内容会发生,特别是如果您使用的是一些不会保留表单数据的古老浏览器返回下一步按钮。使用某些单页面Web应用程序时非常非常糟糕,其中后退会将您带到另一个世界,而下一步甚至不会恢复您的表单,更不用说它的数据了。
I don't like using readonly="readonly", ever. It leaves the field focusable and reachable via tab keypress and, if, god forbid, the user hits the backspace key while the read-only field is focused, then most browsers treat it like the user hit the 'back' button and bring up the previously viewed page. Not what you want to see happen when you're filling out a large form, especially if you are using some archaic browser that doesn't preserve the form data when you hit the 'next' button to return to it. Also very, very bad when using some single-page web application, where 'back' takes you to a whole other world, and 'next' doesn't even restore your form, much less its data.
当我需要禁用字段(或PRE而不是textarea)时,我通过渲染DIV而不是输入字段来解决这个问题。动态并不容易,但我已经设法用AngularJS模板做了相当简短的工作。
I've worked around this by rendering DIVs instead of input fields when I need the field disabled (or PRE instead of a textarea). Not always easy to do dynamically but I've managed to make fairly short work of it with AngularJS templates.
如果你有时间,
这篇关于允许在Firefox浏览器中禁用输入文本框中复制/粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!