ZeroClipboard.setMoviePath( "/zeroclipboard/ZeroClipboard.swf" );
var clip = new ZeroClipboard.Client();
clip.setText( $('textarea#download_me').text() );
clip.glue( 'clip' );
I'm using the popular ZeroClipboard plugin to copy content to user's clipboard. It works perfectly in the dev enviornment as well as on domain1 but not on domain2 with EXACTLY the same files and settings!
/zeroclipboard/ZeroClipboard.js
loads.
/zeroclipboard/ZeroClipboard.swf
does NOT load!
I tried everything but can't get it to work. I'm really confused why it work on domain1 but not on domain2??
How do I resolve this?
Many thanks for your help!
ZeroClipboard.setMoviePath( "/zeroclipboard/ZeroClipboard.swf" );
var clip = new ZeroClipboard.Client();
clip.setText( $('textarea#download_me').text() );
clip.glue( 'clip' );
I'm using the popular ZeroClipboard plugin to copy content to user's clipboard. It works perfectly in the dev enviornment as well as on domain1. but not on domain2. with EXACTLY the same files and settings!
/zeroclipboard/ZeroClipboard.js
loads.
/zeroclipboard/ZeroClipboard.swf
does NOT load!
I tried everything but can't get it to work. I'm really confused why it work on domain1 but not on domain2??
How do I resolve this?
Many thanks for your help!
Share Improve this question edited Mar 10, 2014 at 5:50 Rimian 38.4k17 gold badges125 silver badges119 bronze badges asked Sep 18, 2010 at 12:29 eozzyeozzy 68.7k108 gold badges284 silver badges447 bronze badges 8- you can try to load (full path) – Dezigo Commented Sep 18, 2010 at 12:49
- ZeroClipboard.setMoviePath( "domain2./js/zeroclipboard/ZeroClipboard.swf"); – Dezigo Commented Sep 18, 2010 at 12:49
-
If it
s working.. - it
s a problem with path. – Dezigo Commented Sep 18, 2010 at 12:50 - 1 Tried that too, no luck. BTW, you can edit your ments. – eozzy Commented Sep 18, 2010 at 12:53
- Maybe you have .htaccess file? it can block it.JS file loaded without errors? use (firebug) – Dezigo Commented Sep 18, 2010 at 12:58
6 Answers
Reset to default 2http://kenneth.kufluk./blog/2008/08/cross-domain-javascript-to-flash/ may help. Also beware of subdomains, Flash can get confused. Also use Flash debug player and Fiddler (or similar) to see what is going on.
If this file is located in the same directory as your web page, then it will work out of the box. However, if the SWF file is hosted elsewhere, you need to set the URL like this (place this code after the script tag):
ZeroClipboard.setMoviePath( 'http://YOURSERVER/path/ZeroClipboard.swf' );
To use the new Rich HTML feature available in Zero Clipboard 1.0.7, you must set the movie path to the new "ZeroClipboard10.swf" file, which is included in the 1.0.7 archive. Example:
ZeroClipboard.setMoviePath( 'ZeroClipboard10.swf' );
Or, in a custom location other than the current directory:
ZeroClipboard.setMoviePath( 'http://YOURSERVER/path/ZeroClipboard10.swf' );
There are options for cross domain assets:
// SWF inbound scripting policy: page domains that the SWF should trust. (single string or array of strings)
trustedDomains: [window.location.host],
See: https://github./zeroclipboard/zeroclipboard/blob/master/docs/instructions.md
Also: The current master branch (2.x) logs the cross domains to console if you set debug to true in config.
I had some success using a cdn hosted version of the swf file. But after making some edits this mysteriously stopped working locally but did work on my staging server.
This is my config:
ZeroClipboard.config({
moviePath: '//cdnjs.cloudflare./ajax/libs/zeroclipboard/1.3.2/ZeroClipboard.swf',
forceHandCursor: true,
debug: true
});
Also see this jsfiddle:
http://jsfiddle/rimian/45Nnv/
If you're still having trouble, you can log from the swf to console. For this, you need to be able to pile the flash, from zeroclipboard source into a swf using grunt mxmlc
. Simply dispatch a log event in the action script (pile and copy it into your project) and respond to it in your js:
For example, in ZeroClipboard.as
:
// constructor, setup event listeners and external interfaces
public function ZeroClipboard() {
...
// Get the flashvars
var flashvars:Object = LoaderInfo( this.root.loaderInfo ).parameters;
dispatch("log", flashvars);
...
}
Then in your js:
zeroclipboard = new ZeroClipboard($('.mybuttons'))
zeroclipboard.on('log', function(client, args) { console.log('log:', args)});
Might want to try Fiddler to see exactly what the request/response looks like for the file.
I solved editing this line on ZeroClipboard.min.js
return a+"ZeroClipboard.swf"
to:
return "//YOUR/PATH/TO/ZeroClipboard.swf"
Setting both moviePath and swfPath worked for me.
ZeroClipboard.config({ moviePath: '/assets/ZeroClipboard.swf', swfPath: '/assets/ZeroClipboard.swf', debug: true });