君语贤
时光静好,与君语;细水流年,与君同;繁华落尽,与君老...

实用小技巧>运维相关>正文

ajax动态查询显示网页是否被收录

2019-06-22 14:34 君语贤ajax动态查询否被收录

效果显示:

ajax动态查询显示网页是否被收录

JS代码

$(function () {
	$.getJSON('HTTPS://API.yum6.cn/bAIdu/query.php?url='+window.location.HRef, function(json, textStatus) {
		if (json.state == 1) {
			$('#ae_bdcx').html('本文已被百度收录!');
			$("#ae_bdcx").attr('href','https://www.baidu.com/s?wd='+window.location.href); 
		}else{
			$('#ae_bdcx').html('坐等收录');
			$('#ae_bdcx').css('color','#ff0000');
			$('#ae_bdcx').attr('href','http://zhanzhang.baidu.com/sitesuBMIt/index?sitename='+window.location.href);
			var bp = document.createElement('scrIPt');
			var curProtocol = window.location.protocol.split(':')[0];
			if (curProtocol === 'https') {bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';} 
			else {bp.src = 'http://push.zhanzhang.baidu.com/push.js';}
			var s = document.getElementsBytagName('script')[0];
			s.parentNode.insertBefore(bp, s);
		}
	});
});

文字显示框代码

<span><i class="fa fa-tag fa-fw"></i><a id="ae_bdcx" rel="external nofollow" target="_blank"></a></span>

说明:详情可参考本站的配置。如有疑问,欢迎留言咨询。

本文链接:https://www.weguiding.com/yuwei/547.html