ZeroClipboard - How to use
Solution 1
Ok I got it working, I also think the code posted above by me is correct.
The problem was that I was testing on local, and browsers usually prevent flash from running locally. This is what caused it to fail despite the code being correct.
As a last resort, I uploaded to my web server and tried online, it worked fine.
So, always test ZeroClipboard online after uploading it to your Web Server.
Solution 2
There is a Bug in your Code! Look at the button id-attribute and delete the '#' !
And: If u want more than 1 Clipboard Button on the current Page use the class attribute instead of id.
It works fine now! ;)
Armesh Singh
Updated on June 04, 2022Comments
-
Armesh Singh almost 2 years
I'm using this one http://jonrohan.github.io/ZeroClipboard/
I spent this whole day figuring out how to use ZeroClipboard(ZC). I even read the instructions: https://github.com/jonrohan/ZeroClipboard/blob/master/docs/instructions.md and followed it step by step and couldn't do it.
I tried again and again and again but I just can't get it to work. I even spent hours reading other guides at stackoverflow and other pages both just couldn't get this to work. Moreover, most of the answers are outdated.
Can anyone please write a simple working ZC code that copies a paragraph tag:
<p>Hello, I'm Armesh</p>
Then just tell me simply each part of the ZC code and why you wrote it that way.
I plan to use ZC to copy references generated by my generator: http://anonoz.com/armesh/
This is the code I wrote, all link references are correct:
<!DOCTYPE HTML> <html> <head> <title>Zero Test</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="javascripts/ZeroClipboard.js"></script> </head> <script language="JavaScript"> $(document).ready(function() { var clip = new ZeroClipboard($("#copy_button"), { moviePath: "javascripts/ZeroClipboard.swf" }); }); </script> <body> <button id='#copy_button' data-clipboard-target='to_copy'><b>Copy To Clipboard</b></button> <p id='to_copy'>123456</p> </body> </html>
I also ran the code/web page above in Google Chrome, there are no errors log in the console. It's blank.
-
HartleySan over 10 yearsDoes it work if you run it through localhost (for example, an XAMPP installation on your local Windows machine (if you're using Windows))?
-
Armesh Singh over 10 yearsYes, I was using WAMP. It did not work because it was on localhost. So my browser disabled flash which rendered it not working.
-
HelloWorld1 over 8 yearsI don't understand, I tried your solution and I have a activated flash and still it is not working. How come that it is possible to use it for online only and not in local computer or test environment?