复制到剪贴板不能在firefox和chrome中工作 [英] Copy to clipboard not working in firefox and chrome

查看:211
本文介绍了复制到剪贴板不能在firefox和chrome中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  <script type="text/javascript" language="javascript">
function CopyToClipboard()
{
 var controlValue = currentSelectedRows.data.Key + ' :- ' + currentSelectedRows.data.Summary;
    window.clipboardData.setData('Text', controlValue);
}
    </script>










<div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server"

        Text="Copy Text Box Text to Clip board" OnClientClick="CopyToClipboard()" />
    </div>







此代码在Firefox和Chrome中不起作用

plz帮帮我




This code is not working in Firefox and chrome
plz help me

推荐答案

因为只有IE本身支持,所以不支持跨浏览器。例如,在Chrome中,您在处理粘贴事件时可以获取clipboardData [ ^ ],



Because that is only supported by IE itself, it is not supported cross-browser. In Chrome, for instance, you can get the clipboardData when handling the paste events[^],

var items = e.clipboardData.items;





但是,您必须考虑要求用户手动复制/粘贴内容。这是一种更为跨浏览器的方式为他们完成这项工作。大多数浏览器都不会执行代码,因为他们会认为你的应用程序在他们的机器上推送恶意代码。



But, you must consider asking the user to manually copy/paste the contents. That is a more cross-browser way of doing this job for them. Most browser won't execute the code, because they will consider your application to be pushing malicious code on their machine.


这里你支持这个功能:

http://caniuse.com/#search=clipboard [ ^ ]



以下是您的回答:

http://stackoverflow.com/questions/20509061/window -clipboarddata-getdatatext-doesnt-work-in-chrome [ ^ ]



我的意见是,当每个页面都能读到你的剪贴板时它并不完全安全。



希望它会有所帮助。
Here you have support of this feature:
http://caniuse.com/#search=clipboard[^]

and here is answer to you question:
http://stackoverflow.com/questions/20509061/window-clipboarddata-getdatatext-doesnt-work-in-chrome[^]

And my opinion is, that it is not exactly safe when every page could read you clipboard.

hope it will help.


这篇关于复制到剪贴板不能在firefox和chrome中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆