11

ZeroClipboard doesn't work and it doesn't throw any errors (javascript console).

The website is hosted on a HTTPS webserver running on localhost. Both the website and the SWF are served over HTTPS by the same server.

The SWF is loaded and positioned correctly over the button (with ID: testButton). When right-clicking on the button, the flash context menu (About Adobe Flash Player 11.7...) is shown.

However, none of the events, not even "load", gets fired.

I am working on this problem for two days months now and i can't find a solution.

Additional info:

  • ZeroClipboard version: v1.1.7, also tried v1.2.0-beta.3, edit: This also happens with v1.3.1
  • Browser: Chromium 28 on Mac OSX
  • Official test website is working

Here is my code:

var clip = new ZeroClipboard(document.getElementById("testButton"), {
    moviePath: "media/zeroclipboard.swf"
});
clip.on("dataRequested", function(client, args) {
    client.setText("Copy me!");
});
clip.on("load", function(client) {
    alert("movie is loaded");
});
clip.on("complete", function(client, args) {
    alert("Copied text to clipboard: " + args.text);
});
clip.on("mouseover", function(client) {
    alert("mouse over");
});
clip.on("mouseout", function(client) {
    alert("mouse out");
});
clip.on("mousedown", function(client) {
    alert("mouse down");
});
clip.on("mouseup", function(client) {
    alert("mouse up");
});
squarebrackets
  • 987
  • 2
  • 12
  • 19
  • I'm having the exact same problem. SWF loads (I can see the 200 in Chrome developer tools) but `load` never triggers. – David Tuite Jan 09 '14 at 21:30

5 Answers5

6

After months I finally found a solution:

ZeroClipboard doesn't work out-of-the-box in CommonJS environments in the browser, even it says it does.

The fix for that is assigning the module scope variable (e.g. ZeroClipboard) to the global window object:

ZeroClipboard = require("zeroclipboard");
window.ZeroClipboard = ZeroClipboard;

I created a bug report on this: https://github.com/zeroclipboard/zeroclipboard/issues/332

squarebrackets
  • 987
  • 2
  • 12
  • 19
  • If the fix doesn't work, make sure that `window.require` exists, e.g. by assigning it with `window.require = require;` in one of your modules. These two fixes are very ugly, but they are the only solution at the moment. – squarebrackets Feb 08 '14 at 16:20
1

I'm not sure if this would help~ but have you tried changing your moviePath a little bit? Like this:

{moviePath:"//YOURSERVER/path/ZeroClipboard.swf"}

I was trying to use ZeroCLipboard in the whole month and most of the time I fail because I got the path wrong in one way or another...

Good luck anyways~

Stella
  • 69
  • 3
0

If you extract the project exactly, the .SWF file is located here:

moviePath: "../zeroclipboard.swf"
Conor
  • 168
  • 9
  • 1
    I moved the swf to another directory. The swf is properly loaded (can be seen in the browser's developer tools), but the load event doesn't fire.. – squarebrackets Jan 16 '14 at 11:03
0

I solved editing this line on ZeroClipboard.min.js

return a+"ZeroClipboard.swf"

to:

return "//YOUR/PATH/TO/ZeroClipboard.swf"
Herlon Aguiar
  • 684
  • 2
  • 9
  • 18
0

Would just like to point out for anybody else who finds this question first: ZeroClipboard does not work when looking at the file locally i.e. file://path/index.html. This is because of Adobe's security policies blocking the file:// protocol.

https://stackoverflow.com/a/9450359/710377

If you're already using Node.js at all (even just for the package manager) you can spin up a basic web server on the command line to test ZeroClipboard with npm install http-server -g and http-server /path/ (assuming that npm stuff is already on your path).

Community
  • 1
  • 1
meustrus
  • 6,637
  • 5
  • 42
  • 53