大家好, 我有一个隐藏字段如下。 < input id =hdnKopierModtagereclass =hdnKopierModtageretype =hiddenrunat =server/> 此字段的值在代码隐藏中设置。 点击按钮,我必须将隐藏控件中的文本复制到剪贴板。 我在谷歌搜索了很多,但大多数人建议使用Flash或ZeroClipboard。但是我不能用这个。 我需要一个纯javascript来将文本复制到剪贴板,它应该在以下浏览器中支持(IE,Mozilla和Chrome )。请告诉我如何继续。 提前致谢。
解决方案查看任何代码示例在任何CodeProject文章或答案中。您会在每个代码的右上角看到复制代码锚点(< pre> )元素。单击此锚点并查看其功能。我建议你做同样的事情。它可以帮助读者轻松地以非侵入方式复制剪贴板中的文本,与您尝试的方式形成对比。
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.更多推荐
使用Javascript复制到剪贴板
发布评论