SoFunction
Updated on 2025-04-07

Different js clients display different advertisements (pc end + mobile end + WeChat end)

Core code

var IsSpider=/spider|bot/();
var IsMobile=/ipad|iphone|ipod|android|mobile/();
var IsWeixin=/micromessenger/();

var i;
web=[];
mob=[];
wex=[];
// Ask the headweb['single_question_banner']='pc ad code';
mob['single_question_banner']='Mobile Advertising Code';
wex['single_question_banner']='WeChat Advertising Code';
// Headerweb['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;
    (web[id]);
}

Please refer to the specific code for yourself. The code is relatively simple, mainly by defining the ad code through an array.

How to realize the display of ads on the PC side, but not on the mobile side

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

This is the article about different ads displayed on different js clients (pc side + mobile side + WeChat side) that ends with this article. For more related js clients, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!