Copy code The code is as follows: <br>function copyCode(id){<br>var testCode=document.getElementById(id).value;<br>if(copy2Clipboard(testCode)!=false){<br>alert("The generated code has been copied to Clipboard, you can use Ctrl V to paste it where you need it! ");<br>}<br>}<br>copy2Clipboard=function(txt){<br>if(window.clipboardData){<br>window.clipboardData.clearData();<br>window.clipboardData.setData("Text",txt);<br>}<br>else if(navigator.userAgent.indexOf("Opera")!=-1) {<br>window.location=txt;<br>}<br>else if(window.netscape){<br>try{<br> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");<br>} <br>catch(e){<br> alert("Your firefox security restrictions restrict you from clipboard operations, please open 'about:config' and change <p>Set signed.applets.codebase_principal_support' to true' and try again. The relative path is the firefox root directory</p> <p>record/greprefs/all.js");<br> return false;<br>}<br>var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance</p> <p>(Components.interfaces.nsIClipboard);<br>if(!clip)return;<br>var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance</p> <p>(Components.interfaces.nsITransferable);<br>if(!trans)return;<br>trans.addDataFlavor('text/unicode');<br>var str=new Object();<br>var len=new Object();<br>var str=Components.classes["@mozilla.org/supports-string;1"].createInstance</p> <p>(Components.interfaces.nsISupportsString);<br>var copytext=txt;str.data=copytext;<br>trans.setTransferData("text/unicode",str,copytext.length*2);<br> var clipid=Components.interfaces.nsIClipboard;<br>if(!clip)return false;<br>clip.setData(trans,null,clipid.kGlobalClipboard);<br>}<br>}<br></ script><br><div><br>[<input name="" type="button" value="Copy" onclick="copyCode('txtTestCode1')" />]<br><br> ;<BR><textarea rows=2 id="txtTestCode1" style="width:500px;font-family: Verdana, Arial;font-</P> <P>size:12px;height:55px;border:1px solid #999999;">Copy content 1</textarea><br></div></p> <p></p> </div>