zoukankan      html  css  js  c++  java
  • js中实现 复制到剪切板 功能

    一:引包

      

    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="ZeroClipboard.js"></script>

    二:js代码

      

    function copyContent(){
        //content 为要复制的内容的标识
        $('.content').click(function(){
            $(this).select();
        });
     
        //设置swf路径
        ZeroClipboard.setMoviePath("ZeroClipboard.swf"); 
        //创建对象
        var clip = new ZeroClipboard.Client();
        //设置手型
        clip.setHandCursor(true); 
        //绑定按钮
        clip.glue('copy_btn');
        //复制内容
        clip.addEventListener( "mouseOver", function(client) {
            client.setText($('#content').text());
        });
        //复制成功后的提示
        clip.addEventListener( "complete", function(){    
            alert("copyed successful");     
        }); 
    }

    需要引入    ZeroClipboard.swf。

    所需文件下载地址:http://download.csdn.net/detail/changjn/8462271

  • 相关阅读:
    file
    shell脚本的执行
    添加源,删除源
    lsattr, chattr
    umask
    od
    init
    sync
    wc
    history
  • 原文地址:https://www.cnblogs.com/ssrsblogs/p/4304892.html
Copyright © 2011-2022 走看看