测试
<style type="text/css"> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/ }
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #A31515; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #0000ff; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .type { color: #2B91AF;}
.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; }
.csharpcode .lnum { color: #606060; } </style> <pre class="csharpcode"> function getClipboard() { <span class="kwrd">if</span> (window.clipboardData) { <span class="kwrd">return</span> (window.clipboardData.getData(<span class="str">'Text'</span>)); } <span class="kwrd">else</span> <span class="kwrd">if</span> (window.netscape) { netscape.security.PrivilegeManager.enablePrivilege(<span class="str">'UniversalXPConnect'</span>); var clip = Components.classes[<span class="str">'@mozilla.org/widget/clipboard;1'</span>].createInstance(Components.interfaces.nsIClipboard); <span class="kwrd">if</span> (!clip) <span class="kwrd">return</span>; var trans = Components.classes[<span class="str">'@mozilla.org/widget/transferable;1'</span>].createInstance(Components.interfaces.nsITransferable); <span class="kwrd">if</span> (!trans) <span class="kwrd">return</span>; trans.addDataFlavor(<span class="str">'text/unicode'</span>); clip.getData(trans, clip.kGlobalClipboard); var str = <span class="kwrd">new</span> Object(); var len = <span class="kwrd">new</span> Object(); <span class="kwrd">try</span> { trans.getTransferData(<span class="str">'text/unicode'</span>, str, len); } <span class="kwrd">catch</span> (error) { <span class="kwrd">return</span> <span class="kwrd">null</span>; } <span class="kwrd">if</span> (str) { <span class="kwrd">if</span> (Components.interfaces.nsISupportsWString) str = str.<span class="kwrd">value</span>.QueryInterface(Components.interfaces.nsISupportsWString); <span class="kwrd">else</span> <span class="kwrd">if</span> (Components.interfaces.nsISupportsString) str = str.<span class="kwrd">value</span>.QueryInterface(Components.interfaces.nsISupportsString); <span class="kwrd">else</span> str = <span class="kwrd">null</span>; } <span class="kwrd">if</span> (str) { <span class="kwrd">return</span> (str.data.substring(0, len.<span class="kwrd">value</span> / 2)); } } <span class="kwrd">return</span> <span class="kwrd">null</span>; } function readClipboardData() { var str = getClipboard(); var len = str.split(<span class="str">"\n"</span>); <span class="rem">//获取行数</span>
document.getElementById(<span class="str">"txtContent"</span>).<span class="kwrd">value</span> = str; }</pre>