JQuery implements the copy to clipboard function, and jquery implements clipboard

Source: Internet
Author: User

JQuery implements the copy to clipboard function, and jquery implements clipboard

The replication feature suddenly needs to be used in the project. I found the ZeroClipboard plug-in on the Internet, which is easy to use, but it also has limitations. The usage is as follows:

1. Reference jquery, zclip. js, and swf files.

Demo address: https://github.com/chaoli920029342/jquery_copy

2. Initialization

<Body> <input type = "text" name = "text" id = "text" value = "http://www.baidu.com"/> <a href = "javascript: void (0) "rel =" external nofollow "id =" dynamic "> copy </a> <script type =" text/javascript ">$ (document ). ready (function () {$ ("# dynamic "). zclip ({path: 'ZeroClipboard.swf ', copy: $ (' # text '). val (), beforeCopy: function () {// some code}, afterCopy: function () {alert ($ ("# text "). val () ;}}); // beforeCopy afterCopy is optional}); </script> </body>

Note:

1. Run localhost on the server

2. js + swf implementation. files must be introduced at the same time. ZeroClipboard provides a transparent flash for interaction with the cut version. When you click the copy button on the page, the required content is transmitted to Flash, then, copy the input content to the Clipboard through the Flash copy function. Make sure that the flash is correctly loaded.

3. compatible with various browsers

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.