摘要
百度主动推送JS改良版,优化了加载速度与其他识别问题,并且代码变的更长长长了。具体详见http://zhanzhang.baidu.com/college/articleinfo?id=1587
资讯
目前的JS代码是这样的,然而它的工作效率非常低,还会给你的网站带来莫名其妙的报错404。性能也比较低下,并且影响你的网站加载速度。
目前官方进行了改良,也就是这么长一串了。解决了许多的问题,还不错,提高了性能与效率。
下载
你可以通过下面的代码来进行自定义修改。目前后台还没有跟进更新。
<script>
(function(){
var canonicalURL, curProtocol;
//Get the <link> tag
var x=document.getElementsByTagName("link");
//Find the last canonical URL
if(x.length > 0){
for (i=0;i<x.length;i++){
if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
canonicalURL=x[i].href;
}
}
}
//Get protocol
if (!canonicalURL){
curProtocol = window.location.protocol.split(':')[0];
}
else{
curProtocol = canonicalURL.split(':')[0];
}
//Get current URL if the canonical URL does not exist
if (!canonicalURL) canonicalURL = window.location.href;
//Assign script content. Replace current URL with the canonical URL
!function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
</script>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(9)
https://www.baidu.com/s?wd=%5B%E8%B5%84%E8%AE%AF%5D%E7%99%BE%E5%BA%A6%E7%AB%99%E9%95%BF%E6%94%B9%E7%89%88%E4%B8%BB%E5%8A%A8%E6%8E%A8%E9%80%81JS%E4%BB%A3%E7%A0%81,%E4%BD%A0%E6%9B%B4%E6%96%B0%E4%BA%86%E5%90%97?
:舔冰棍: 本篇文章使用最新版代码推送,已经被秒收录了。
月宅NB,月宅NB!原来的js我是几乎都加载不出来
你抠的顶部图……
哇,终于更新了,之前浏览器控制台就一直出现百度的404链接,而且最近还提交不上去 :尴尬:
emmm,后台post提交就好,前端拖速度
:狂吐口水: 留着备用,现在用不上
:暴走表情8: