使用Javascript复制到剪贴板

编程入门 行业动态 更新时间:2024-10-28 17:13:37
本文介绍了使用Javascript复制到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我有一个隐藏字段如下。 < input id =hdnKopierModtagereclass =hdnKopierModtageretype =hiddenrunat =server/> 此字段的值在代码隐藏中设置。 点击按钮,我必须将隐藏控件中的文本复制到剪贴板。 我在谷歌搜索了很多,但大多数人建议使用Flash或ZeroClipboard。但是我不能用这个。 我需要一个纯javascript来将文本复制到剪贴板,它应该在以下浏览器中支持(IE,Mozilla和Chrome )。请告诉我如何继续。 提前致谢。

解决方案

查看任何代码示例在任何CodeProject文章或答案中。您会在每个代码的右上角看到复制代码锚点(< pre> )元素。单击此锚点并查看其功能。我建议你做同样的事情。它可以帮助读者轻松地以非侵入方式复制剪贴板中的文本,与您尝试的方式形成对比。
-SA

Hi All, I have a hidden field as below. <input id="hdnKopierModtagere" class="hdnKopierModtagere" type="hidden" runat="server" /> The value of this field is set in the code-behind. On clicking a button, i have to copy the text from the hidden control to the clipboard. I have searched in google a lot, but most of them recommend to use Flash or ZeroClipboard. But I can't use this. I need a pure javascript to copy the text to the clipboard and it should be supported in following browsers (IE, Mozilla and Chrome). Kindly advice me know how to proceed. Thanks in advance.

解决方案

Look at any code sample in any CodeProject article or answer. You will see "Copy code" anchors over the right top corner of each code ("<pre>") element. Click at this anchor and see what it does. I suggest you do exactly the same thing. It helps the reader to easily copy the text in the clipboard in a non-intrusive manner, in contrast to what you are trying to do.
—SA

更多推荐

使用Javascript复制到剪贴板

本文发布于:2023-11-14 02:28:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1585982.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:剪贴板   Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!