Some time ago wrote a blog about the micro-trust built-in browser does not display the alliance ads
Based on Window.navigator.userAgent to determine whether the current browser is a micro-mail built-in browser
window.navigator.useragent== ' Micromessenger '
Today I want to share the same content, because I only considered the adaptation of the micro-trust browser, back in the mobile browser to open the site, find the adaptation problem.
Some alliances will automatically block the mobile end, but some alliances can not be shielded, so only manually to judge.
According to the browser useragent to judge the source
The useragent judgment of the Android device
Navigator.userAgent.match (/android/i)
iphone device useragent judgment
Navigator.userAgent.indexOf (' IPhone ')!=-1
ipad Device useragent Judgment
Navigator.userAgent.indexOf (' IPad ')!=-1
ipod device useragent judgment
Navigator.userAgent.indexOf (' IPod ')!=-1
In addition, the method of judging the micro-letter built-in browser
function Isweixin () {
var ua = Window.navigator.userAgent.toLowerCase ();
if (Ua.match (/micromessenger/i) = = ' Micromessenger ') {return
true;
} else {return
false
;
}}
Shielded micro-letters, mobile phones (except Winphone devices), ipod
if (!isweixin () &&! ( Navigator.userAgent.match (/android/i) | | (Navigator.userAgent.indexOf (' IPhone ')!=-1) | | (Navigator.userAgent.indexOf (' IPod ')!=-1) | | (Navigator.userAgent.indexOf (' IPad ')!=-1)) {
var sogou_ad_id=4767753; Federation AD Billing ID
}
<script src= "http://images.sohu.com/cs/jsfile/js/c.js" charset= "Utf-8" ></script >//advertising content loading
If there is no affiliate billing ID, the following ads will naturally not be displayed. Indirectly played the role of Mobile end shielding Alliance advertising.