复主代码 代码如下: CSS/Javascript 데모<br> function test(){<br> copyToClipboard("dddd");<br> }<br> copyToClipboard = function(txt) {<br>if(window.clipboardData) {<br> window.clipboardData.clearData();<br> window.clipboardData.setData("Text", txt);<br>} else if(navigator.userAgent.indexOf ("Opera") != -1) {<br>window.location = txt;<br>} else if (window.netscape) {<br>try {<br>netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect ");<br>} catch (e) {<br>alert("您적firefox 보안 보호试");<br>return false;<br>}<br>varclip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);<br> if (!clip)<br>return;<br>var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);<br>if (!trans )<br>return;<br>trans.addDataFlavor('text/unicode');<br>var str = new Object();<br>var len = new Object();<br>var str = 구성요소. 클래스["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);<br>var copytext = txt;<br>str.data = copytext;<br>trans.setTransferData(" text/unicode",str,copytext.length*2);<br>var Clipid = Components.interfaces.nsIClipboard;<br>if (!clip)<br>return false;<br>clip.setData(trans,null ,clipid.kGlobalClipboard);<br>}<br>}<br> 复제到粘贴板 설명:Firefox의 보안은 JavaScript에서 제어할 수 없습니다. codebase_principal_support"设置为"true"。