我想试试这个DEMO使用 ZeroClipboard 将文本复制到剪贴板。我有一个包含 index.html、ZeroClipboard.js 和 ZeroClipboard.swf 的本地文件夹。但它不起作用:
<html>
<body>
<script type="text/javascript" src="ZeroClipboard.js"></script>
<script type="text/javascript">
//set path
ZeroClipboard.setMoviePath('ZeroClipboard.swf');
//create client
var clip = new ZeroClipboard.Client();
//event
clip.addEventListener('mousedown', function () {
clip.setText(document.getElementById('box-content').value);
});
clip.addEventListener('complete', function (client, text) {
alert('copied: ' + text);
});
//glue it to the button
clip.glue('copy');
</script>
<textarea name="box-content" id="box-content" rows="5" cols="70">
The David Walsh Blog is the best blog around! MooTools FTW!
</textarea>
<br />
<br />
<p>
<input type="button" id="copy" name="copy" value="Copy to Clipboard" />
</p>
</body>
</html>