ZeroClipboard SWF not loading

ZeroClipboard.setMoviePath( "/zeroclipboard/ZeroClipboard.swf" ); var clip = new ZeroClipboard.Client(); clip.setText( $('textarea#download_me').text() ); clip.glue( 'clip' ); 

I use the popular ZeroClipboard plugin to copy content to the user's clipboard. It works great both in the enviornment environment and on domain1.com, but not on domain2.com with EXACTLY the same files and settings!

/zeroclipboard/ZeroClipboard.js loading.

/zeroclipboard/ZeroClipboard.swf NOT loading!

I tried everything but couldn't make it work. I am really confused why it works on domain1 but not on domain2 ??

How do i solve this?

Many thanks for your help!

+7
javascript jquery flash clipboard zeroclipboard
source share
6 answers

http://kenneth.kufluk.com/blog/2008/08/cross-domain-javascript-to-flash/ can help. Also beware of subdomains, Flash may get confused. Also use Flash debug player and Fiddler (or similar) to see what happens.

+2
source share

If this file is in the same directory as your web page, it will work out of the box. However, if the SWF file is located elsewhere, you need to set the URL as follows (put this code after the script tag):

  ZeroClipboard.setMoviePath( 'http://YOURSERVER/path/ZeroClipboard.swf' ); 

To use the new rich HTML function available in Zero Clipboard 1.0.7, you must set the path to the new ZeroClipboard10.swf file, which is included in the 1.0.7 archive. Example:

  ZeroClipboard.setMoviePath( 'ZeroClipboard10.swf' ); 

Or in a user place other than the current directory:

  ZeroClipboard.setMoviePath( 'http://YOURSERVER/path/ZeroClipboard10.swf' ); 
+2
source share

There are options for inter-regional 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.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md

Also: the current main branch (2.x) registers cross-domains on the console if you set the debug value to true in config.

I have had some success using a version of the SWF file that supports cdn. But after making some changes, it mysteriously stopped working locally, but it worked on my intermediate server.

This is my configuration:

  ZeroClipboard.config({ moviePath: '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.3.2/ZeroClipboard.swf', forceHandCursor: true, debug: true }); 

Also see this jsfiddle:
http://jsfiddle.net/rimian/45Nnv/

If you still have problems, you can go from SWF to the console. To do this, you need to compile flash memory from the zeroclipboard source to swf using grunt mxmlc . Just send the log event to the script action (compile and copy it into your project) and respond to it in 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)}); 
+2
source share

You can try Fiddler to see what the request / response for the file looks like.

0
source share

I decided to change this line to ZeroClipboard.min.js

 return a+"ZeroClipboard.swf" 

in

 return "//YOUR/PATH/TO/ZeroClipboard.swf" 
0
source share

Both moviePath and swfPath worked for me.

 ZeroClipboard.config({ moviePath: '/assets/ZeroClipboard.swf', swfPath: '/assets/ZeroClipboard.swf', debug: true }); 
0
source share

All Articles