<div class="codetitle"> <span><a style="CURSOR: pointer" data="57136" class="copybut" id="copybut57136" onclick="doCopy('code57136')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code57136"> <br><html xmlns="http://www.w3.org /1999/xhtml"> <br><머리> <br><title>支持ie는 FireFox의 剪切板代码</title> <br><script type="text/javascript"> <br>function setCopy(_sTxt){ <br>시도{ <br>if(window.clipboardData){ <br>window.clipboardData.setData("Text", _sTxt); <br>} else if(window.netscape) {//FireFox搞得真复杂呀 <br>netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); <br>var 클립 = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); <br>if(!clip) return; <br>var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(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(Components.interfaces.nsISupportsString); <br>var copytext = _sTxt; <br>str.data = 카피텍스트; <br>trans.setTransferData("text/unicode", str, copytext.length*2); <br>var clipsid = Components.interfaces.nsIClipboard; <br>(!clip)이 false를 반환하는 경우; <br>clip.setData(trans, null,clipid.kGlobalClipboard); <br>} <br>}catch(e){} <br>} <br></script> <br></head> <br><본문> <br><input type="button" onclick="setCopy('hello');" value="复system" /> <br><div> <br>Firefox/3.0.14下可以运行<br /> <br>Firefox/3.5.3下无效<br /> <br>不过多考虑这一块了。 <br></div> <br></body> <br></html><br> </div> <br><br>下面是ie firefox 读取剪切板中的信息적방법<br><div class="codetitle"> <span><a style="CURSOR: pointer" data="48850" class="copybut" id="copybut48850" onclick="doCopy('code48850')"><u>复제代码</u></a></span> 代码如下:</div> <div class="codebody" id="code48850"> <br>function getClipboard() <br>{ <br>if (window.clipboardData) <br>{ <br>return (window. clipsboardData.getData('text')); <br>} <br>else <br>{ <br>if (window.netscape) <br>{ <br>try <br>{ <br>netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); <br>var 클립 = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance(Components.interfaces.nsIClipboard); <br>if (!clip) <br>{ <br>return; <br>} <br>var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable); <br>if (!trans) <br>{ <br>return; <br>} <br>trans.addDataFlavor("text/unicode"); <br>clip.getData(trans,clip.kGlobalClipboard); <br>var str = new Object(); <br>var len = new Object(); <br>trans.getTransferData("text/unicode", str, len); <br>} <br>catch (e) <br>{ <br>alert("您적firefox안전한 보안을 제조하기 위해 제조, 请打开'about:config'将signed.applets.codebase_principal_support'设置为true '저지저하중, 파이어폭스/greprefs/all.js"); <br>널을 반환합니다. <br>} <br>if (str) <br>{ <br>if (Components.interfaces.nsISupportsWString) <br>{ <br>str = str.value.QueryInterface(Components.interfaces.nsISupportsWString); <br>} <br>else <br>{ <br>if (Components.interfaces.nsISupportsString) <br>{ <br>str = str.value.QueryInterface(Components.interfaces.nsISupportsString); <br>} <br>else <br>{ <br>str = null; <br>} <br>} <br>} <br>if (str) <br>{ <br>return (str.data.substring(0, len.value / 2)); <br>} <br>} <br>} <br> null을 반환합니다. <br>} <br> </div> <br>下面是 즉,firefox下 写入剪切板的代码<br><div class="codetitle"> <span><a style="CURSOR: pointer" data="26823" class="copybut" id="copybut26823" onclick="doCopy('code26823')"><u>复主代码</u></a></span> 代码如下:</div> <div class="codebody" id="code26823"> <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> catch(e){ <br> 화재 경고(" Fox 보안 제한으로 인해 클립보드 작업이 제한됩니다. '정보: config'를 설정하고 signed.applets.codebase_principal_support'를 true'로 설정한 후 다시 시도하십시오. 상대 경로는 firefox 루트 디렉토리/greprefs/all.js"); > varclip=Components.classes['@mozilla.org/widget/ 클립보드;1'].createInstance(Components.interfaces.nsIClipboard); <br> if(!clip)return; <br> var trans=Components.classes ['@mozilla.org/widget/transferable;1'].createInstance (Components.interfaces.nsITransferable); <br> if(!trans)return; <br> trans.addDataFlavor('text/unicode') <br> var str=new Object(); Object(); <br> var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(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; .setData(trans,null,clipid.kGlobalClipboard); <br> } <br>}<br><br><br>특정 애플리케이션의 경우 Script House의 코드를 참조할 수 있습니다.</div>