如何安装ZeroClipboard? [英] How to install ZeroClipboard?
问题描述
根据其网站上的说明: https://github.com /jonrohan/ZeroClipboard/blob/master/docs/instructions.md
As per instructions at their website: https://github.com/jonrohan/ZeroClipboard/blob/master/docs/instructions.md
我复制并粘贴了页面底部的最小示例,并复制了2个文件
I copy and pasted the minimal example at the bottom of the page, and copied the 2 files
ZeroClipboard.swf&
ZeroClipboard.js
ZeroClipboard.swf & ZeroClipboard.js
进入我网站的根目录。
我似乎无法让按钮工作。我错过了什么吗?
I can't seem to get the button working. Am I missing something?
推荐答案
在基本示例中,您需要包含ZeroClipboard.js脚本。我添加了:
In the basic example you need to include the ZeroClipboard.js script. I added:
<script src="ZeroClipboard.js"></script>
到html head部分。然后 - 这对我来说也不是那么清楚 - 需要在按钮之后添加main.js脚本。我没有引用该文件(据我所知,它不在包中),但直接包含了脚本 - 这样:
to the html head section. Then - which was not so clear for me either - the main.js script needs to be added after the button. I didn't reference the file (which isn't in the package as far as I could tell), but included the script directly - this way:
<button id="copy-button" data-clipboard-text="Copy Me!" title="Click to copy me.">Copy to Clipboard</button>
<script type="text/javascript">
var client = new ZeroClipboard( document.getElementById("copy-button") );
client.on( "ready", function( readyEvent ) {
// alert( "ZeroClipboard SWF is ready!" );
client.on( "aftercopy", function( event ) {
// `this` === `client`
// `event.target` === the element that was clicked
event.target.style.display = "none";
alert("Copied text to clipboard: " + event.data["text/plain"] );
} );
} );
</script>
希望这有助于某人(超过一年的时间,我猜你要么解决了,要么继续前进! !)
Hope this helps somebody (more than one year on I gues you have either solved it or moved on!!)
这篇关于如何安装ZeroClipboard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!