With the development of mobile networks, more and more people use mobile phones and other mobile terminals to browse Web pages for office work. If a large Alliance advertisement is displayed when the mobile phone opens the page, the user experience will be very poor, after some research, the following method is used to realize that mobile Browsers Do Not Display PC advertisements. I wrote a blog post about built-in browsers that do not display Alliance ads.
Determine whether the current browser is a built-in browser based on window. navigator. userAgent.
window.navigator.userAgent=='micromessenger'
The content to be shared today is similar, because previously we only considered browser adaptation, and turned back to the mobile browser to open the site and found the adaptation problem.
Some consortium automatically blocks mobile terminals, but some consortium cannot block them, so they can only be judged manually.
Determine the source based on the browser userAgent
UserAgent judgment for Android devices
navigator.userAgent.match(/Android/i)
Iphone userAgent judgment
navigator.userAgent.indexOf('iPhone')!=-1
UserAgent judgment for ipad devices
navigator.userAgent.indexOf('iPad') != -1
Ipod device userAgent judgment
navigator.userAgent.indexOf('iPod') != -1
Add the built-in browser judgment method.
function isWeiXin() { var ua = window.navigator.userAgent.toLowerCase(); if (ua.match(/MicroMessenger/i) == 'micromessenger') { return true; } else { return false; } }
Shielded, mobile phone (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; // consortium advertising billing id}