问题描述
我向用户发送敏感信息,希望他们能够复制(用于在其他地方粘贴),但不能直接查看。
I am sending sensitive information to my users that I would like them to be able to copy (for pasting elsewhere) but not see directly.
-
填充数据的密码框,但这不会't允许
他们复制文本。
Populate an password box with the data, but this doesn't allowthem to copy the text.
使文本颜色与背景颜色相同。然而,I
恐怕我的用户甚至不知道有文本到
副本。他们只会坐在那里,去我没有看到任何文字!即使
,如果我非常明确地指出他们应该做什么,那么
的文本仍然可以看到它被选中时。
Make the text color the same as the background color. However, I am afraid that my users will not even know that there is text to copy. They will just sit there and go "I don't see a any text!" Even if I do point out very explicitly what they are supposed to do, then the text will still be visible when it is selected.
创建某种on_copy事件,当
用户复制星号时,将传递文本。我知道如何使用jQuery的bind()
检测副本,但我没有找到一个方法来更改实际
被复制。
Create some kind of on_copy event that will pass the text when a user copies the asterisks. I know how to use jQuery's bind() to detect a copy, but I have not found a way to change what actually gets copied.
最后和最少:用javascript和剪贴板
管理。我真的不想去那里,因为它需要
闪存。
Last and least: Something fancy with javascript and clipboard management. I really don't want to go there as it would require flash.
推荐答案
这样做...你创建一个包含hidden文本的 div
或输入
与 opacity 0.001
, focus()
,并设置它的选择对整个内容要复制的人)通过javascript并以某种方式通知用户按 Ctrl + C
来复制数据(可能有一个类似JavaScript的弹出式事件,停留几秒钟供用户阅读)。
How about this... you make a div
or input
containing the "hidden" text with opacity 0.001
, focus()
it and set it's selection on the whole content (which should be the text you want the person to copy) via javascript and somehow inform the user to press Ctrl+C
to copy the data (possibly with an javascript popup-like event that stays there for a few seconds for the user to read it).
这篇关于掩码文本,但仍允许用户复制它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!