JS to achieve IE across the browser copy content to the Clipboard

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.