以下是完整版代码:
<!DOCTYPE html>
<html>
<head>
<title>Zero Clipboard 测试</title>
<meta charset="utf-8">
<script type="text/javascript" src="ZeroClipboard.js"></script>
</head>
<body>
<p id="wenben">你要复制的文本</p>
<button id='anniu' class='my_clip_button' data-clipboard-target='wenben'>点击复制</button>
</body>
</html>
<script type="text/javascript">
<!--注意:这里new的时候,需要写按钮的ID,不能带引号哦!-->
var clip = new ZeroClipboard( anniu, {
moviePath: "ZeroClipboard.swf"
} );
clip.on( 'complete', function(client, args) {
alert("复制成功,复制内容为:"+ args.text);
} );
</script>
好了,需要的伙伴们,可以复制一下去测试了哦!测试的时候要在服务器环境下。
ZeroClipboard 走的是flash,所以在手机上是不支持的哦!
所需文件下载地址:http://pan.baidu.com/s/1c2q38UO 密码:u1yk