zeroclipboard不工作 [英] zeroclipboard not working

查看:78
本文介绍了zeroclipboard不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图使用这个插件:



http://code.google.com/p/zeroclipboard/wiki/Instructions



它基本上允许你设置剪贴板通过使用Flash电影技巧的JavaScript文本



我做了

  ZeroClipboard.setMoviePath('/pathtoswf/zeroclipboard.swf'); 
var clip = new ZeroClipboard.Client();
clip.setHandCursor(false);
clip.setText('lalalalala');
clip.glue('i_container','i_button');
clip.addEventListener('onLoad',function(){alert('loaded baby');});
clip.addEventListener('onMouseDown',function(){alert('mouse is down');});
clip.addEventListener('onComplete',function(){alert('text got copy to clipboard');});

与html

 < div id =i_containerstyle =position:relative> 
< div id =i_button>
某物
< / div>
< / div>

zeroclipboard js加载正常

所以当我运行这个,它警告加载的宝贝就好了,所以闪光灯也显示正常,但当我点击东西文本时,它不警告鼠标停下来,也没有提醒文本被复制到剪贴板,也没有文本实际上被复制到剪贴板



我做错了什么?

解决方案

你是从磁盘上的本地文件运行吗?正如此处所述,由于存在安全限制,零剪贴板可能无法在本地磁盘上运行由Adobe。您可能需要 http:// https:// 网址。



您可以通过此处解决此问题并将路径添加到您的本地ZeroClipboard.swf文件到受信任的文件列表中。您也可以尝试全部允许选项。

说了上面的话,当我将它安装在我的开发环境中时,我没有做任何这些!我只是使用 wiki说明中提供的完整示例对其进行测试。我将.swf文件粘贴在与网页本身相同的目录中,并且工作正常。可能首先尝试一个简化的剪切和粘贴测试。

演示示例还包含函数(客户端){... 你的addEventListener处理程序只有 function(){... 。这可能可以解释为什么你没有得到onMouseDown和onComplete的警报,但我不确定为什么警告为onLoad工作。


so I'm trying to use this plugin:

http://code.google.com/p/zeroclipboard/wiki/Instructions

which basically allows you to set clipboard text via javascript by using a flash movie trick

I did

    ZeroClipboard.setMoviePath( '/pathtoswf/zeroclipboard.swf' );
    var clip = new ZeroClipboard.Client();
    clip.setHandCursor( false );
    clip.setText('lalalalala');
    clip.glue( 'i_container', 'i_button' ); 
    clip.addEventListener( 'onLoad', function(){ alert('loaded baby'); } );
    clip.addEventListener('onMouseDown', function(){ alert('mouse is down'); });
    clip.addEventListener('onComplete', function(){ alert('text got copied to clipboard'); });

with the html

<div id="i_container" style="position:relative">
<div id="i_button">
Something
</div>
</div>

zeroclipboard js is loaded just fine

so when I run this, it alerts "loaded baby" just fine so the flash also gets displayed fine but then when I click on the "something" text it doesn't alert mouse is down nor does it alert that the text got copied to the clipboard, nor is the text actually get copied to clipboard

what did I do wrong?

解决方案

Are you running from a local file on disk? As it says here, Zero Clipboard might not work from local disks due to the security restrictions placed by Adobe. You may need to have an http:// or https:// url.

You can work around this by going here and adding the path to your local "ZeroClipboard.swf" file to the trusted files list. You could also try the "allow all" option.

Having said the above, when I installed it in my dev environment I didn't do any of that!! I just tested it using the "Complete Example" provided in the wiki instructions. I stuck the .swf file in the same directory as the webpage itself and it worked fine. Maybe try a simplified cut-and-paste test first up.

The demo example also has function(client){... where you just have function(){... for your addEventListener handlers. That would probably explain why you get no alerts for onMouseDown and onComplete, although I'm not sure why the alert worked for the onLoad.

这篇关于zeroclipboard不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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