<script type= "Text/javascript" >
function Copycode (ID) {
var Testcode=document.getelementbyid (ID). value;
if (Copy2clipboard (testcode)!=false) {
Alert ("The generated code has been copied to the Clipboard, you can use CTRL + V to paste it where you want it!") ");
}
}
Copy2clipboard=function (TXT) {
if (window.clipboarddata) {
Window.clipboardData.clearData ();
Window.clipboardData.setData ("Text", txt);
}
else if (navigator.userAgent.indexOf ("Opera")!=-1) {
Window.location=txt;
}
else if (Window.netscape) {
try{
Netscape.security.PrivilegeManager.enablePrivilege ("Universalxpconnect");
}
catch (e) {
Alert ("Your Firefox security restrictions restrict you from clipboard operation, please open ' about:config ' to ' Set Signed.applets.codebase_principal_support ' to true ' and try again, The relative path is the Firefox root directory/greprefs/all.js ");
return false;
}
var clip=components.classes[' @mozilla. Org/widget/clipboard;1 '].createinstance ( Components.interfaces.nsIClipboard);
if (!clip) return;
var trans=components.classes[' @mozilla. Org/widget/transferable;1 '].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-string;1"].createinstance ( Components.interfaces.nsISupportsString);
var Copytext=txt;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);
}
}
</script>
<div>
<a href= "#" target= "_blank" > [<a href= "#" onclick= "Copycode (' txtTestCode1 '); return false;" > click Copy 1</a>]
<textarea rows=2 id= "TxtTestCode1" style= "Width:500px;font-family:verdana, arial;font-size:12px;height:55px; border:1px solid #999999; " > Copy Content 1</textarea>
</div>
<div>
<a href= "#" target= "_blank" > [<a href= "#" onclick= "Copycode (' TxtTestCode2 '); return false;" > click Copy 2</a>]
<textarea rows=2 id= "TxtTestCode2" style= "Width:500px;font-family:verdana, arial;font-size:12px;height:55px; border:1px solid #999999; " > Copy Content 2</textarea>
</div>
<div>
<a href= "#" target= "_blank" > [<a href= "#" onclick= "Copycode (' txtTestCode3 '); return false;" > click Copy 3</a>]
<textarea rows=2 id= "TxtTestCode3" style= "Width:500px;font-family:verdana, arial;font-size:12px;height:55px; border:1px solid #999999; " > Copy Content 3</textarea>
</div>