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-ins require Flash support and remember to install Adobe Flash Player when you use them.
1. Jquery-zclip Plug-in website
zeroclipboard.swf
2. Jquery-zclip usage
Introducing Jquery-zclip-related JS and SWF files
<script type= "Text/javascript" src= "<%=path%>/resources/js/jquery.min.js" ></script><script Type= "Text/javascript" src= "<%=path%>/resources/js/jquery.zclip.min.js" ></script><script type= "Text/javascript" >$ (function () { $ ("#cp-btn"). Zclip ({ path: ' <%=path%>/resources/js/ Zeroclipboard.swf ',//remember to introduce zeroclipboard.swf into the project copy:function () { return $ (' #inviteUrl '). Val (); } );}); </script><div class= "Form-row" > <div class= "col-md-5" > <input class= "Form-control" Value= "" id= "Inviteurl"/> </div> <div class= "col-md-1" > <a href= "Javascript:void ( 0) "id=" cp-btn " class=" btn btn-default btn-block Btn-clean "> Complex </a> </div ></div>
Configuration Instructions
path:swf path (replication mainly uses Flash to resolve different browser replication)
Copy: What you want to copy, either static or return dynamic content
Beforecopy: The function to be done before copying;
Aftercopy: function to be done after copying;
3 methods are available
Show:$ (selected). Zclip (' show ');//copy function valid
Hide:$ (selected). Zclip (' hide ');//Invalid copy function
Remove:$ (selected). Zclip (' remove ');//Completely remove the copy function
3. Demo Effect
After successful operation, click the Copy button, a prompt box will appear, indicating that the copy to the Clipboard takes effect, as follows:
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" is OK, the effect is as follows:
jquery Plugin: Cross-browser replication Jquery-zclip