" />
    首页 > 建站‧营销

百度和360站长平台提交网址链接的js代码


改良版本的百度索引自动推送脚本

<script>
//改良版本的百度索引自动推送脚本
	(function(){
		var canonicalURL, curProtocol;
		//Get the  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>

这个新脚本的作用是多了一步查看页面的canonical URL的步骤。canonical属性具体写法:

<link rel="canonical" href="当前页面URL" />

360站长平台自动收录js代码:

<script>(function(){
var src = (document.location.protocol == "http:") ? "http://js.passport.qihucdn.com/11.0.1.js?3c78c49cf51a0802e9561f3b32b30d61":"https://jspassport.ssl.qhimg.com/11.0.1.js?3c78c49cf51a0802e9561f3b32b30d61";
document.write('<script src="' + src + '" id="sozz"><\/script>');
})();
</script>

自动收录功能js代码添加,请将js代码安装到要提交的页面</body>前

本文链接:https://zhanque.net/cms/2927.html