This demo supports a variety of browser replication, pro-Test available (Ie8,ie9,ie10, Firefox, Google).
Zeroclipboard (:https://github.com/zeroclipboard/zeroclipboard) is used in this demo.
This demo must be in the server environment, the browser directly open invalid.
This demo requires the introduction of 3 files: Jquery.min.js, ZeroClipboard.min.js, and zeroclipboard.swf.
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "UTF-8"><title>Copy to Clipboard demo</title><Scripttype= "Text/javascript"src= "/webtest/js/jquery.min.js"></Script><Scripttype= "Text/javascript"src= "/webtest/js/zeroclipboard.min.js"></Script></Head><Body> <inputtype= "button"value= "Copy current page URL"class= "My_copy" ></Body><Scripttype= "Text/javascript">$(function() { varURL=window.location.href; Try{//Support ZeroclipboardZeroclipboard.config ({swfpath:"/webtest/js/zeroclipboard.swf" } ); $(". My_copy"). each (function(i) {varClient= NewZeroclipboard ($ ( This)); Client.on ("Copy", function(event) {varClipboard=Event.clipboarddata; Clipboard.setdata ("Text/plain", URL); Alert ('the current page link has been copied to the Clipboard! '); //clipboard.setdata ("text/html", "<b>copy me!</b>"); //clipboard.setdata ("Application/rtf", "{\\rtf1\\ansi\n{\\b Copy me!}}"); }); }); }Catch(e) {//Zeroclipboard not supported $(". My_copy"). each (function(i) {$ ( This). On ("Click", function(){ varRes=Window.clipboardData.setData ("Text", encodeURI (URL)); if(res) {alert ('the collection link has been copied to the Clipboard! '); } }); }); } })</Script></HTML>
"JavaScript" Copy to Clipboard feature (support for various browsers currently)