pc端粘贴复制插件使用ZeroClipboard

来源:互联网 发布:sql进阶教程 编辑:程序博客网 时间:2024/05/21 21:46

通过点击按钮,进行复制粘贴

1、先去官网ZeroClipboard.org现在v2.2.0.zip

2、解压后,找到ZeroClipboard.js和ZeroClipboard.swf,放入开发项目中。注意路径

3、var client = new ZeroClipboard(document.getElementById("copy-button"));    //document.getElementById("copy-button")被点击的按钮
            client.on( "ready", function(readyEvent) {   //开始阶段
                 alert( "ZeroClipboard SWF is ready!" );
                client.on('copy', function (event) {     //复制阶段
                    event.clipboardData.setData('text/plain', content);   //content为复制的内容,比如:某个元素的innerText
                    alert("复制成功");
                });
                client.on( "aftercopy", function(event) {   //复制后
                    // `this` === `client`
                    // `event.target` === the element that was clicked
                    alert("Copied text to clipboard: " );
                } );
            } );


这个插件目前还不支持客户端。


0 0