美文网首页
百度站长平台链接提交-js代码推送进化版

百度站长平台链接提交-js代码推送进化版

作者: 诗无尽头i | 来源:发表于2018-09-23 15:46 被阅读137次

百度站长工具链接提交 js 代码推送进化版,听说优化了加载速度和其它问题,和原提交代码相比变长支持 https://网站等,原文来自百度站长学院。


image.png

使用方法和原来的代码一样,复制下面的代码放到你喜欢放的地方当然要能用才行。

<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>

原文:http://zhanzhang.baidu.com/college/articleinfo?id=1587

相关文章

网友评论

      本文标题:百度站长平台链接提交-js代码推送进化版

      本文链接:https://www.haomeiwen.com/subject/rlqqoftx.html