js/swf -> 复制文字到剪贴板

careyourself 2017-08-18

通过JS + FLASH 的形式可 完美的 解决浏览器的兼容问题。

需要文件 swfobject.js ,  clipboard.swf ,  用于显示的 图片 (flash_copy_btn.png) 。见附件

<span id="forLoadSwf"></span>
<script src="{$domain}static/swfobject.js" type="text/javascript"></script>
<script type="text/javascript">
    var copyCon = "343";
    var flashvars = {
        content: encodeURIComponent(copyCon),
        uri: '{$domain}static/flash_copy_btn.png'
    };
    var params = {
        wmode: "transparent",
        allowScriptAccess: "always"
    };
    swfobject.embedSWF("{$domain}static/clipboard.swf", "forLoadSwf", "52", "25", "9.0.0", null, flashvars, params);

    function copySuccess(){
        //flash回调
        alert("复制成功!");
    }
</script>

相关推荐