This article will combine examples to explain how to use a jquery based plug-in--zclip to copy content to the Clipboard function. In fact, ie there is a way to achieve click Replication, but because only ie unique, so we do not advocate. And Zclip is to use a hidden Flash file to complete the function of replication, the key is that it is compatible with the current mainstream browsers.
In web development, to allow users to copy a section of the page code, URL and other information, in order to avoid the user drag the mouse and then the right button copy operation and possible errors, we can directly in the page to place a copy button, just a little bit of this copy button, the content will be copied, The user can then paste where they want to paste.
First you need to load the jquery library and Zclip plug-ins in the page, these two files have been packed, welcome to download.
We then add the following code to the body section of the page:
The page is placed with an input box textarea, of course, it can be other HTML elements, then a copy button, can also be linked text form.
When you click on "Copy Content", call the Zclip plug-in, and prompt replication success, see Code:
|1 2 3 4 5 6 7 8 9 10 11||
It is worth noting that if the content is copied from input box inputs, textarea, and so on, the Copy object uses:
|1 2 3||
If the content is copied from the page element Div, p, and so on, the Copy object uses:
Copy: $ (' #mytext '). Text ();
This completes the ability to copy content to the Clipboard.