How to implement mobile end browser does not display PC-side ads _javascript Tips

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.