码迷,mamicode.com
首页 > 其他好文 > 详细

ZeroClipBoard 兼容IE浏览器的 多个复制

时间:2014-12-24 18:08:52      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:javascript   zeroclipboard   

一开始去ZeroclipBoard 官网下载最新版本(2.x),后来才发现根本就不支持IE浏览器,IE浏览器打开官网也是报错。

ZeroclipBoard 的git有一段说明:

ZeroClipboard v2.x is expected to work in IE9+ and all of the evergreen browsers.
Although support for IE7 & IE8 was officially dropped in v2.0.0,
 it was actuallystill technically supported through v2.0.2.

https://github.com/zeroclipboard/zeroclipboard


现在改成1.x版本,兼容IE浏览器:

    /**
     * @description 复制 为了兼容IE9- ZeroClipboard 放弃2.x使用1.x版本
     * @param $o
     * @param text
     */
    function initCopy($o, text) {
        if (typeof text == 'undefined') {
            if (typeof $o.value != 'undefined') {
                text = $o.value;
            } else if (typeof $o.innerHTML != 'undefined') {
                text = $o.innerHTML;
            } else {
                text = 'NULL';
            }
        }
        var client = new ZeroClipboard($o);
        client.on('load', function (client) {
            client.on('datarequested', function (client) {
                client.setText(text);
            });

            client.on('complete', function (client, args) {
                alert('复制成功 ' + text);
            });
        });
        client.on('wrongflash noflash', function () {
            alert('flash error');
            ZeroClipboard.destroy();
        });
    }


ZeroClipBoard 兼容IE浏览器的 多个复制

标签:javascript   zeroclipboard   

原文地址:http://blog.csdn.net/default7/article/details/42125925

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!