1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

mobileDetection - Append a Query String

Discussion in 'JavaScript' started by l3l00, Jun 23, 2013.

  1. #1
    I have this code that uses an if screen.width is > 490 then window.location = "..."

    What I want to do instead is use parse ini files to check for a query string inside the ini file which will append on the index page and continue over to the other pages something like, "?option=mobile"

    My pages use upsells so it needs to check for the screen size only once (to save on bandwidth)
    l3l00, Jun 23, 2013 IP
  2. tonicc

    tonicc Active Member

    Likes Received:
    Best Answers:
    Trophy Points:
    At the beginning of the page:
    <script type="text/javascript">
    if( navigator.userAgent.match(/Android/i)
    || navigator.userAgent.match(/webOS/i)
    || navigator.userAgent.match(/iPhone/i)
    || navigator.userAgent.match(/iPod/i)
    || navigator.userAgent.match(/BlackBerry/i)
    || navigator.userAgent.match(/Windows Phone/i)
        window.location.href = "http://yoursite.com/?option=mobile"
    Code (markup):
    It detects if the browser is a Mobile and redirect to http://yoursite.com/?option=mobile. Hope this help!

    tonicc, Jun 26, 2013 IP