Alex Dai Playground

[javascript] copy cut no-flash - clipboard.js

| Comments

https://github.com/zenorocha/clipboard.js
http://codepen.io/netsi1964/full/QbLLGW/
http://www.oxxostudio.tw/articles/201510/clipboard-js.html
http://www.infoq.com/cn/news/2015/10/clipboard-js-no-flash

Example
<input id="foo" type="text" value="hello">
<button class="btn" data-clipboard-action="cut" data-clipboard-target="#foo">Copy</button>

<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.1/clipboard.min.js"></script>

<script>
var clipboard = new Clipboard('.btn');
clipboard.on('success', function(e) {
console.log(e);
});
clipboard.on('error', function(e) {
console.log(e);
});
</script>

document.execCommand()

Comments

comments powered by Disqus