The realization principle of Zero clipboard
Zero Clipboard use transparent flash to let it float on top of the Copy button, so that the click is not a button but flash, so that the required content into the flash, and then through the Flash copy function to copy the incoming content to the Clipboard.
Installation method of Zero clipboard
In fact, it is not installed, is to use the preparation before the work.
First need to download Zero Clipboard compression package, unzip the folder after the two files: Zeroclipboard.js and zeroclipboard.swf put into your project download address: http://file.111cn.net/ Download/2013/06/03/zeroclipboard-1.0.7.tar.gz
The code is as follows |
Copy Code |
<script type= "Text/javascript" src= "Zeroclipboard.js" ></script> |
Note: The above zeroclipboard.js, zeroclipboard.swf need to be placed under the same path. You can use Zeroclipboard.setmoviepath ("Flash path") If you are not on the same path;
To set the zeroclipboard.swf address
The code is as follows |
Copy Code |
Zero Clipboard enables simple Cross-browser replication var clip = new Zeroclipboard.client (); Create a new object Clip.sethandcursor (TRUE); Set Mouse to hand type Clip.settext ("haha"); Sets the text to copy. Registers a button with the parameter ID. Clicking on this button will copy it. This button does not necessarily require an input button, or it can be another DOM element. Clip.glue ("Copy-botton"); // |
And the previous position is not interchangeable so that the basic skills can be achieved, click the button can copy the set of text. You may notice that the text to be copied is fixed, and what to do if you want to change dynamically, such as copying the contents of an input box