点击复制,获取本页面URL地址,支持IE、谷歌

<!--<br/ /><br/ />Code highlighting produced by Actipro CodeHighlighter (freeware)<br/ />http://www.CodeHighlighter.com/<br/ /><br/ />--> 1     <script type="text/javascript"> 
 2 var clipBoardContent=document.location; 
 3 clipBoardContent+='\r\n';
 4 function copy_clip(meintext)
 5 {
 6  if (window.clipboardData) 
 7    {
 8    window.clipboardData.setData("Text", meintext);
 9    }
10    else if (window.netscape) 
11    { 
12    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
13    var clip = Components.classes['@mozilla.org/widget/clipboard;1']
14                  .createInstance(Components.interfaces.nsIClipboard);
15    if (!clip) return;
16    var trans = Components.classes['@mozilla.org/widget/transferable;1']
17                   .createInstance(Components.interfaces.nsITransferable);
18    if (!trans) return;
19    trans.addDataFlavor('text/unicode');
20    
21    var str = new Object();
22    var len = new Object();
23    
24    var str = Components.classes["@mozilla.org/supports-string;1"]
25                 .createInstance(Components.interfaces.nsISupportsString);
26    
27    var copytext=meintext;
28    
29    str.data=copytext;
30    
31    trans.setTransferData("text/unicode",str,copytext.length*2);
32    
33    var clipid=Components.interfaces.nsIClipboard;
34    
35    if (!clip) return false;
36    
37    clip.setData(trans,null,clipid.kGlobalClipboard);
38    
39    }
40    return false;
41 }
42 
43 var o = clipBoardContent;
44 function copyURL()
45 {
46 copy_clip(o);
47 
48 alert("复制成功!");
49 }
50     </script>

展开阅读全文

没有更多推荐了,返回首页