你的位置:首页 > 软件开发 > Java > 如何强制在访问博客园博客的时候变成博客园分配的二级域名方式

如何强制在访问博客园博客的时候变成博客园分配的二级域名方式

发布时间:2015-03-25 16:01:13
因为我自己开了一个百度统计想玩玩,定义了一个域名是echofool.cnblogs.com。但是博客园默认访问一个人的博客时 都是采用的子目录方式,比如:http://www.cnblogs.com/echofool/ 。这里我取巧利用了博客园可自定义页头页脚的方式改了这个url ...

因为我自己开了一个百度统计想玩玩,定义了一个域名是echofool.cnblogs.com。

但是博客园默认访问一个人的博客时 都是采用的子目录方式,比如:http://www.cnblogs.com/echofool/ 。

这里我取巧利用了博客园可自定义页头页脚的方式改了这个url。

 1 (function(){ 2   function fixAnchor(anchor){ 3     if(anchor){ 4       if(anchor.pathname.indexOf("/echofool/")==0){ 5         var url="http://echofool.cnblogs.com/"+anchor.pathname.replace("/echofool/","")+anchor.search+anchor.hash; 6         anchor.href=url; 7       }else if(anchor.pathname.indexOf("echofool/")==0){ 8         var url="http://echofool.cnblogs.com/"+anchor.pathname.replace("echofool/","")+anchor.search+anchor.hash; 9         anchor.href=url;10       }11     }12   }13   var a=document.createElement("a");14   a.href=window.location.href;15   if(a.pathname.indexOf("/echofool/")==0){16     var url="http://echofool.cnblogs.com/"+a.pathname.replace("/echofool/","")+a.search+a.hash;17     window["\u006c\u006f\u0063\u0061\u0074\u0069\u006f\u006e"]["\u0068\u0072\u0065\u0066"]=url;18   }else if(a.pathname.indexOf("echofool/")==0){19     var url="http://echofool.cnblogs.com/"+a.pathname.replace("echofool/","")+a.search+a.hash;20     window["\u006c\u006f\u0063\u0061\u0074\u0069\u006f\u006e"]["\u0068\u0072\u0065\u0066"]=url;21   }22   window.onload=function(){23     var anchors=document.getElementsByTagName("a");24     for(var i=0;i<anchors.length;i++){25       fixAnchor(anchors[i]);26     }27   };28 })();

原标题:如何强制在访问博客园博客的时候变成博客园分配的二级域名方式

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录