js实现的复制兼容chrome和IE


IE js代码:
复制代码 代码如下:

<script type="text/javascript">
function copyUrl2()
{
var Url2=document.getElementById("biao1");
Url2.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
alert("已复制好,可贴粘。");
}
</script>
<textarea cols="20" rows="10" id="biao1">用户定义的代码区域</textarea>
<input type="button" onClick="copyUrl2()" value="点击复制代码" />

chrome JS代码:
复制代码 代码如下:

<script src="http://www.weicaiyun.com/assets/js/copy/ZeroClipboard.js"></script>

<script type="text/javascript">

var clip = new ZeroClipboard.Client();
clip.setHandCursor( true );
clip.setText('复制内容');
clip.glue('button');

</script>

<input type="button" id="button" value="点击复制代码" />

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3