複製代碼 代碼如下: <BR>function copyCode(id){<BR>var testCode=document.getElementById(id).value;<BR>if(copy2Clipboard(testCode)!=false){<BR>alert("產生的程式碼已經複製到貼上的板程式碼已經複製到貼上,你可以用Ctrl V 貼到需要的地方去了哦! .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("UniversalX"); >catch(e){<BR> alert("您的firefox安全限制限制您進行剪貼簿操作,請開啟'about:config'將<BR> <BR>signed.applets.codebase_principal_support'設定為true'之後重試,相對路徑為firefox根目<BR> <BR>錄/greprefs/all.js");<BR> return false;<BR>}<BR>var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance<🎜illa.org/widget/clipboard;1'].createInstance <P>(Components.interfaces.nsIClipboard);if(!clip)return;<P>var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance<BR> <BR>(Components.interfaces.nsITransferable);<BR>if(!trans)return;trans.addDataFlavor('text/unicode');<P>var str=new Object();<BR>varcode');<BR>var str=new Object();var len=new Object();<P>var str=Components.classes["@mozilla.org/supports-string;1"].createInstance<BR> <BR>(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;if(!clip)return false;<P>clip.setData(trans,null,clipid.kGlobalClipboard);<BR>}<BR>}<BR>}<BR> [] size:12px;height:55px;border:1px solid #999999;">複製內容1