兼容IE和FF:复制本页地址 收藏本页地址 复制当前页地址和标题

今天终于解决了这个困扰我很久的难题!

“复制本页地址 收藏本页地址 复制当前页地址和标题” 跨浏览器同时兼容IE和FF,现将代码记下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>双节棍吧-双节棍视频网站-sjg8.com</title>

<script type="text/javascript" charset="GB2312">
   var browser=(function getBrowser(){var b=navigator.userAgent.toLowerCase();return{safari:/webkit/.test(b),opera:/opera/.test(b),ie6:/msie 6/.test(b)&&!/opera/.test(b),ie7:/msie 7/.test(b)&&!/opera/.test(b),msie:/msie/.test(b)&&!/opera/.test(b),mozilla:/mozilla/.test(b)&&!/(compatible|webkit)/.test(b)};})();function $(sId){return document.getElementById(sId);}
function jLoader(source,autoRemove,id,charset){id=id||"";charset=charset||"gb2312";autoRemove=autoRemove||false;var b=document.getElementsByTagName("head")[0];var c=document.createElement("script");c.type="text/javascript";c.charset=charset;if(id){c.id=id;}
c.src=source;var remove=function(){c.οnlοad=null;var h=c.parentNode;h.removeChild(c);delete c;};var e=function(h){var j=(h?h:window.event).target?(h?h:window.event).target:(h?h:window.event).srcElement;if(j.readyState=="loaded"||j.readyState=="complete")
{j.onreadystatechange=null;if(autoRemove){remove();}}};if(navigator.product=="Gecko"&&autoRemove){c.οnlοad=remove;}
else{c.onreadystatechange=e;}
b.appendChild(c);}
function copyClip(text2copy){if(window.clipboardData) {window.clipboardData.setData("Text",text2copy);}else{prompt("请复制地址:",text2copy);return false;}
return true;}
function copy(s){if(copyClip(s)){alert("复制成功啦");}
return false;}
function addBookmark(url,title){url=url||document.location.href;title=title||document.title;if(window.sidebar){window.sidebar.addPanel(title,url,"");}else if(document.all){window.external.AddFavorite(url,title);}else if(window.opera&&window.print){return true;}
return true;}
</script>
</head>
<body>
<a href="#" οnclick="copy(document.location.href);">复制地址</a><p>
<a οnclick="copy(document.location.href+'\n\r'+document.title)" href="#">复制地址和标题!</a><p>
<a href="#" οnclick="addBookmark();">收藏本页</a><p>
</body>
</html>
效果演示:http://www.sjg8.com/Shipin/tvshow/954.html  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值