Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

Emlog检测百度收录插件代码文章页ajax查询

前言:

今天在其他博客发现了一个Emlog文章页ajax查询是否被百度收录的代码,现在分享给大家。

通过ajax查询文章页百度收录判断,能优化网页加载白屏时间!

提醒一下这里用的是别人的API接口,如果不喜欢可以自己做一个。

正文:

该接口同样还带有js自动推送功能,可省去已被收录的文章进行反复推送的加载时间。

Emlog检测百度收录插件代码文章页ajax查询插图

1、把js到模版js文件中即可,建议放到jquery.min.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);
		}
	});});

2、找到并打开echo_log.php文件,并在需要显示的位置添加如下代码即可

<a id="ae_bdcx" rel="external nofollow" target="_blank"></a>

温馨提示:接入CDN的需要清理刷新缓存才可看到效果。

温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
未整理

小本创业,实体餐饮技术配方教程视频

2021-5-6 0:00:00

未整理

一键生成营销号专稿子源码

2021-5-8 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索