对于非ie浏览器他是用flash来实现的,js代码如下:
![](http://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<script type="text/javascript">
function copy_code(copyText)
{
if (window.clipboardData)
{
window.clipboardData.setData("Text", copyText)
}
else
{
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="../js/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(copyText)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
document.getElementById(flashcopier).innerHTML = divinfo;
}
alert('copy成功!');
}
</script>
<input id="inputTest" type="button" value="测试" onclick="copy_code('拷贝成功!帆船书会http://www.fanchuanbook.com')" />
那个flash文件从这里下载:下载