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.