IE, firefox compatible edition, which is always required to be copied to the system clipboard
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "> <Script type =" text/javascript "> // <! [CDATA [function copy_clip (copy) {if (window. clipboardData) {window. clipboardData. setData ("Text", copy);} else if (window. netscape) {netscape. security. privilegeManager. enablePrivilege ('universalxpconnect '); var clip = Components. classes ['@ mozilla.org/widget/clipboard1_1').createinstance (Components. interfaces. nsIClipboard); if (! Clip) return; var trans = Components. classes ['@ mozilla.org/widget/transferable1_1'assist.createinstance (Components. interfaces. nsITransferable); if (! Trans) return; trans. addDataFlavor ('text/unicode '); var str = new Object (); var len = new Object (); var str = Components. classes ["@ mozilla.org/supports-string1_1"]. createInstance (Components. interfaces. nsISupportsString); var copytext = copy; str. data = copytext; trans. setTransferData ("text/unicode", str, copytext. length * 2); var clipid = Components. interfaces. nsIClipboard; if (! Clip) return false; clip. setData (trans, null, clipid. kGlobalClipboard);} alert ("copied" + copy) return false ;} //]> script, please save another code for testing <input type = "text" id = "ff" value = "www.blueidea.com"/> <button onclick = "copy_clip (document. getElementById ('ff '). value) "> copy </button>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]