Js implements cross-browser copying of IE content to the clipboard

Source: Internet
Author: User

We all know that using the general method, we cannot copy the content across browsers, and there is no way to copy the content to the clipboard under ff, next, I will introduce a Zero Clipboard plug-in to implement cross-Browser IE copying content to the Clipboard. For more information, see.

Implementation principle of Zero Clipboard
Zero Clipboard uses transparent Flash to float the copy button. In this way, you can click not a button but Flash, so that you can pass the required content into Flash, then, copy the input content to the Clipboard through the Flash copy function.

How to install Zero Clipboard
In fact, it is not the installation, that is, preparations before use.
First, download the compressed Zero Clipboard package, decompress the package, and put the two files in the folder: ZeroClipboard. js and zeroclipboard.swf into your project.Carrier address: http://file.bKjia. c0m/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 preceding ZeroClipboard. js and ZeroClipboard.swf must be placed in the same path. If the path is not the same, use ZeroClipboard. setMoviePath ("Flash path ");

To set the zeroclipboard.swf address

The Code is as follows: Copy code

Zero Clipboard for simple cross-browser Replication
Var clip = new ZeroClipboard. Client (); // create an object
Clip. setHandCursor (true); // set the mouse to the Hand Type
Clip. setText ("Haha"); // set the text to be copied.
// Register a button with the parameter id. Click this button to copy it.
// This button is not necessarily an input button or other DOM elements.
Clip. glue ("copy-botton ");//

And the last sentence cannot be changed, so that the basic function is implemented, click the button to copy the set text. You may have noticed that the text to be copied is fixed. What if you want to change it dynamically, such as copying the content in an input box?

Related Article

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.