javascript获取本页面URL地址

【网上购物论坛】-IT泡吧![Www.itpob.Cn]网上购物社区! - Powered by Discuz!
http://www.itpob.cn/

 

点击复制,获取本页面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>

 

<!--<br/ /><br/ />Code highlighting produced by Actipro CodeHighlighter (freeware)<br/ />http://www.CodeHighlighter.com/<br/ /><br/ />--> 1               < href ="#"  onclick ="copyURL()"  style ="text-decoration: none" > [推荐好友] </ a >
2 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值