欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js不同客戶端顯示不同廣告(pc端+移動(dòng)端+微信端)

 更新時(shí)間:2023年02月09日 20:57:40   投稿:mdxy-dxy  
這篇文章主要介紹了js不同客戶端顯示不同廣告(pc端+移動(dòng)端+微信端),比較適合自適應(yīng)網(wǎng)站的廣告,需要的朋友可以參考下

核心代碼

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=[];
// 提問(wèn)頭部
web['single_question_banner']='pc端廣告代碼';
mob['single_question_banner']='移動(dòng)端廣告代碼';
wex['single_question_banner']='微信端廣告代碼';
// 標(biāo)題頭部
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]);
}

具體的代碼大家自行參考。代碼比較簡(jiǎn)單,主要是通過(guò)數(shù)組定義廣告代碼。

js如何實(shí)現(xiàn)廣告在pc端顯示,移動(dòng)端不顯示

var browser={    
		versions:function(){            
				var u = navigator.userAgent, app = navigator.appVersion;            
				return {                
					trident: u.indexOf('Trident') > -1,               
					presto: u.indexOf('Presto') > -1,                
					webKit: u.indexOf('AppleWebKit') > -1,              
					gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,               
					mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/),          
					ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),                 
					android: u.toLowerCase().indexOf('android') > -1 ,   
					iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1,               
					iPad: u.indexOf('iPad') > -1,               
					webApp: u.indexOf('Safari') == -1           
				};
				}()
}
if (!(browser.versions.android || browser.versions.ios || browser.versions.iPhone || browser.versions.iPad)){
 
document.writeln("<div class=\'float_layer\' id=\'miaov_float_layer\' style=\'z-index:10001;\'>");
document.writeln("    <div class=\'content\'>");
document.writeln("        <div class=\'wrap\'> ");
document.writeln("        <a href=\'http://yookee.cc/\' target=\'_blank\'><img src=\'/ad1/14690989051188.gif\' width=\'300\' height=\'250\' /></a>");
document.writeln("        </div>");
document.writeln("    </div>");
document.writeln("</div>");
}

到此這篇關(guān)于js不同客戶端顯示不同廣告(pc端+移動(dòng)端+微信端)的文章就介紹到這了,更多相關(guān)js不同客戶端顯示不同廣告內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論