zClip不起作用-多次复制到剪贴板JS [英] zClip don't work - multiple copy to clipboard JS

查看:98
本文介绍了zClip不起作用-多次复制到剪贴板JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试创建复制到剪贴板"按钮,但我不知道为什么无法做到这一点. 我用ajax加载页面,所以当我将鼠标悬停在按钮上时,我调用一个函数将zclip添加到按钮中.但是当我单击它时,什么都没有发生. 这是我的代码: JS:

I try to make a copy to clipboard button but I don't know why I can't make it. I load my page with ajax so I call a function to add the zclip to my button when I mouseOver the button. But when I click on it, nothing is happening. Here are my codes: JS :

<script type="text/javascript" src="<?php echo JS_DIR?>zclip.min.js"></script>
<script type="text/javascript">
    function mouseOver(){
        $('.copyMails').each(function (k,n) {
            console.log("test");
            var copyMails = $(this);
            $(this).zclip({
                path: '<?php echo JS_DIR?>ZeroClipboard.swf',
                copy: function () {
                    var val = $(copyMails).attr('data-clipboard-text'); 
                    return val;
                },
                afterCopy: function () { console.log($(copyMails).data('clipboard-text') + " was copied to clipboard"); }
          });
        });
    }
</script>

还有我的按钮:

<button onmouseover="mouseOver()" data-clipboard-text="<?php echo implode(',', $emails); ?>" class="copyMails" title="Copier les adresses emails">
    Copier les adresses emails
</button>

谢谢.

推荐答案

我无法在服务器上使用它,我从zclips网站下载了ZeroClipboard.swf,但无法使用.我注意到zclips网站上的swf并不是他们用于示例的swf.因此,我创建了指向 http://www.steamdev.com/zclip/js/ZeroClipboard的超链接.swf ,然后单击另存为",将大小与我最初下载的大小进行了比较,它更大.因此,我将上面链接中的新服务器放到了服务器上,并且运行良好.

I could not get this to work on my server, I downloaded the ZeroClipboard.swf from zclips website and would not work. I noticed that the swf on zclips website in not the one that they use for their examples. So I created a hyperlink to http://www.steamdev.com/zclip/js/ZeroClipboard.swf and clicked "save link as" compared the size to the one I had downloaded originally and it was bigger. So I put the new one from the link above onto my server and it worked perfectly.

我认为,如果您直接从zclips网站的下载链接下载了swf,那是您的问题,因为这是我的.尝试将我的链接另存为文件,然后将其上传到您的服务器.

I think if you downloaded the swf from zclips website directly from their download link, this is your problem as it was mine. Try saving my link as a file and then uploading it to your server.

这篇关于zClip不起作用-多次复制到剪贴板JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆