Js 之复制到剪切板

一、下载

https://github.com/zenorocha/clipboard.js/archive/master.zip

二、Demo示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input id="foo" type="text" value="hello">
<button class="btn" data-clipboard-action="copy" data-clipboard-target="#foo">Copy</button>
<script src="./clipboard/clipboard.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>

</body>
</html>

三、第三方Demo地址

http://www.webkaka.com/Blog/ARCHIVES/demo/clipboard.js-master/demo/index.html

上一篇:光标移动快捷键


下一篇:javascript – 标准体中是否有任何动作来支持复制到剪贴板的安全方式?