Jquery+flash (Zclip) enables click to copy to Clipboard

Source: Internet
Author: User

Jquery-zclip is a jquery plugin that replicates content to the Clipboard, and we don't have to consider compatibility issues between different browsers and browser versions. Jquery-zclip plug-in requires Flash support, remember to install Adobe Flash Player when you use it.

To load jquery and zclip, please change the address according to their respective storage address.

<script type= "Text/javascript" src= "js/jquery.js" ></script><script type= "Text/javascript" src= "js/ Jquery.zclip.min.js "></script>

JS implementation Click to copy the code (local test can not be used, upload to the server test)

$ (function () {$ (' #copy_input '). Zclip ({path: ' js/zeroclipboard.swf ', copy:function () {//copy content        return $ (' #mytext '). Val ();         }, Aftercopy:function () {///Copy succeeded $ ("<span id= ' msg '/>"). InsertAfter ($ (' #copy_input ')). Text (' copy succeeded '); }    });});

Note that if the copied content comes from input box inputs, textarea, and so on, the Copy object uses:

Copy:function () {return $ (' #mytext '). Val ();

If the copied content comes from a page element Div, p, and so on, the Copy object uses:

Copy: $ (' #mytext '). Text ();

Configuration Instructions
path:swf path (replication is mainly used to resolve the replication of different browsers with Flash) copy: The content to be copied, can be static content, can also return dynamic content beforecopy: Copy before the function;aftercopy: function to be done after copying;

3 methods are available

Show:$ (selected). Zclip (' show '); The copy function is valid hide:$ (selected). Zclip (' hide '); The copy function is invalid remove:$ (selected). Zclip (' remove '); Complete removal of replication functionality

After successful operation, click the Copy button and a prompt will pop up indicating that the copy to the Clipboard is in effect.

Pop-up box appears "Copied Text to Clipboard" English characters, a bit inconsistent with the Chinese people use the habit, change it to "successfully copied to the Clipboard", in the Jquery.zclip.min.js file found "Copied text to clipboard" replaced by "Successfully copied to the Clipboard" will be OK.

For more information, please refer to http://www.steamdev.com/zclip/

Disclaimer: This article uses BY-NC-SA agreement to authorize, reprint also please specify: Jquery+flash (zclip) realize click Copy to Clipboard

Jquery+flash (Zclip) enables click to copy to Clipboard

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.