首页 > 其他 > 详细

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

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

一开始去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浏览器的 多个复制

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!