如何创建一个用户可以复制文本的弹出框? [英] How to create a popup box where users can copy text?
问题描述
在我的HTML页面中,我生成一个链接,用户可以在其中抓取用于处理事物的链接。我需要以某种方式给用户链接他们可以看到链接,然后将链接复制到剪贴板。
我不是指通过代码复制到剪贴板,只需手动选择文本并单击 ctrl + c
或右键单击+复制
即可。
有没有办法让我创建一个弹出框您可以选择并复制?
这需要适用于所有浏览器(IE8 +)(Firefox)(Chrome)(特别是 IE8 ) 。所以,如果我使用警报框,我将无法复制文本,所以我不能使用警报。
是否有一些非常简单的方法,不涉及很多的代码,也没有使用另一个HTML文件的弹出框或什么的。
我甚至可以使用jquery,如果这使得它很容易。真的,只是一种显示用户可以复制文本的弹出窗口的方法,这一切都通过代码完成。
谢谢。
您可以尝试使用window.prompt()并执行如下操作: http://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt 您可以从输入中复制文本,这可以默认到链接。
In my HTML page I generate a link, where users can grab to use for things. I need to somehow give the user the link where they can see the link and then copy the link to clip board.
I don't mean copy to clip board through code, just manually selecting the text and clicking ctrl+c
or right click+copy
is ok.
Is there a way I can create a popup box where it has text there that you can select and copy?
This needs to work with all browsers (IE8+) (Firefox) (Chrome) (especially IE8). So if I use alert box, I will not be able to copy the text so I can't use alerts.
Is there some really easy way that doesn't involve lots of code and also not using another HTML file for the popup box or something.
I can even use jquery if that makes it easy. Really, just a way to show a popup where the user can copy the text, and this is all done with code.
Thanks.
You could try and use window.prompt() and do something like this: http://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt where you can copy the text from the input, which can default to the link.
这篇关于如何创建一个用户可以复制文本的弹出框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!