How to automatically forward phone users to mobile version of site?

Discussion in 'Mobile Web Development' started by deenybird, Oct 13, 2008.

  1. deenybird

    deenybird New Member

    Joined:
    Aug 10, 2008
    Messages:
    126
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    I would like to have cell phone users be automatically forwarded to the mobile version of my site (ex. www.site.com forwards to m.site.com).

    thanks for the advice
  2. dabomb1022

    dabomb1022 Banned

    Joined:
    Feb 10, 2008
    Messages:
    1,288
    Likes Received:
    34
    Device:
    2G iPod touch
    heres how add this to your page:
    Code:
    if((navigator.userAgent.match(/iPhone/i)) ||
    (navigator.userAgent.match(/iPod/i)))
    {
    location.href='http://www.yoursite.com';
    }
    
    hope this helps!
  3. deenybird

    deenybird New Member

    Joined:
    Aug 10, 2008
    Messages:
    126
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    sweet, i'll try this first thing in the morning,
    does this go in any specific spot in the html code?
  4. dabomb1022

    dabomb1022 Banned

    Joined:
    Feb 10, 2008
    Messages:
    1,288
    Likes Received:
    34
    Device:
    2G iPod touch
    Wait I forgot to put the script tags just read it from iwebkit.net/computer/effects.html
  5. deenybird

    deenybird New Member

    Joined:
    Aug 10, 2008
    Messages:
    126
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    thanks so much dabomb, that link answered things perfectly.
  6. dabomb1022

    dabomb1022 Banned

    Joined:
    Feb 10, 2008
    Messages:
    1,288
    Likes Received:
    34
    Device:
    2G iPod touch
    your welcome if you need more help just pm me
  7. Winterboard

    Winterboard Well-Known Member

    Joined:
    Dec 26, 2007
    Messages:
    2,345
    Likes Received:
    53
    Device:
    iPad 2 (Black)

Share This Page