Mozilla Firefox&;ASP.NET中与Internet Explorer兼容的剪贴板

Mozilla Firefox&;ASP.NET中与Internet Explorer兼容的剪贴板,asp.net,internet-explorer,firefox,clipboard,Asp.net,Internet Explorer,Firefox,Clipboard,我需要用ASP.NET将文本框中的文本复制到剪贴板。我想要一个可与Mozilla Firefox和IE媲美的代码。Internet Explorer剪贴板副本非常简单: // set the clipboard var x = 'Whatever you want on the clipboard'; window.clipboardData.setData('Text',x); // get the clipboard data window.clipboardData.getData('T

我需要用ASP.NET将文本框中的文本复制到剪贴板。我想要一个可与Mozilla Firefox和IE媲美的代码。

Internet Explorer剪贴板副本非常简单:

// set the clipboard
var x = 'Whatever you want on the clipboard';
window.clipboardData.setData('Text',x);

// get the clipboard data
window.clipboardData.getData('Text');

Firefox,一点也不平凡。除非您已经签署了脚本等,否则纯JS实际上是不可能的。不过,使用Flash对象有一个解决方法。阅读相关信息

对于非IE浏览器,请使用此全球通用的脚本。谷歌搜索“_clipboard.swf”文件。(不过,由于安全原因,此代码在最新的Flash 10上不起作用)

var flashcopier=‘flashcopier’

     if(!document.getElementById(flashcopier)) {
        var divholder = document.createElement('div');
        divholder.id = flashcopier;
        document.body.appendChild(divholder);
     }

     document.getElementById(flashcopier).innerHTML = '';
     var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+encodeURIComponent('YOUR_VALUE_FOR_CLIPBOARD')+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
     document.getElementById(flashcopier).innerHTML = divinfo;
if(!document.getElementById(flashcopier)){
var divholder=document.createElement('div');
divholder.id=闪光灯复印机;
文件.正文.附件(股东);
}
document.getElementById(flashcopier).innerHTML='';
var divinfo=“”;
document.getElementById(flashcopier).innerHTML=divinfo;