核心代码
var IsSpider=/spider|bot/ig.test(window.navigator.userAgent);
var IsMobile=/ipad|iphone|ipod|android|mobile/ig.test(window.navigator.userAgent);
var IsWeixin=/micromessenger/i.test(window.navigator.userAgent);
var i;
web=[];
mob=[];
wex=[];
// 提问头部
web['single_question_banner']='pc端广告代码';
mob['single_question_banner']='移动端广告代码';
wex['single_question_banner']='微信端广告代码';
// 标题头部
web['single_question_bottom']='';
mob['single_question_bottom']='';
wex['single_question_bottom']='';
if (IsMobile) {
for (i in web) {
web[i] = mob[i];
}
}
function growing(id) {
if(IsSpider)return;
document.writeln(web[id]);
}
具体的代码大家自行参考。代码比较简单,主要是通过数组定义广告代码。
原文地址: