1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Show ads only to mobile users

Discussion in 'Styling and Customization Questions' started by tajhay, Dec 13, 2013.

  1. tajhay

    tajhay Well-Known Member

    Hi guys,
    Is there a conditional that i can use so that i only show ads to mobile users / people using the responsive format?

    Greatly appreciated.
     
  2. oman

    oman Well-Known Member

    Is it with adsense ads? Or other ads?
     
  3. tajhay

    tajhay Well-Known Member

    adsense mate - plan to use responsive ads that they provide. the only problem is i want a conditional so that only mobile users see it.
     
  4. oman

    oman Well-Known Member

    tajhay likes this.
  5. oman

    oman Well-Known Member

  6. tajhay

    tajhay Well-Known Member

    oman likes this.
  7. caliman

    caliman Active Member

    You can always use javascript user agent kind of stuff.

    Code:
    var isMobile = {
        Android: function() {
            return navigator.userAgent.match(/Android/i);
        },
        BlackBerry: function() {
            return navigator.userAgent.match(/BlackBerry/i);
        },
        iOS: function() {
            return navigator.userAgent.match(/iPhone|iPad|iPod/i);
        },
        Opera: function() {
            return navigator.userAgent.match(/Opera Mini/i);
        },
        Windows: function() {
            return navigator.userAgent.match(/IEMobile/i);
        },
        any: function() {
            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
        }
    };
    Then use conditionals...

    Code:
    if( isMobile.any() ) { do something };
    
    or specific...
    
    if( isMobile.iOS() )  { do something };
    
     
  8. Jeremy

    Jeremy XenForo Moderator Staff Member

    You can't conditionally render HTML by mobile users unless you wrote an add-on that analyzed the user agent.
     

Share This Page