Help Please With Cell Phone Redirect

Discussion in 'HTML & Website Design' started by ChristopherLeeMaher.Com, Jun 2, 2010.

  1. #1
    Hey, I am trying to redirect all mobile(cell) phones that visit my site to http://m.domain.tld/
    I am using
    
    <script type="text/javascript">
    	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)) {
    		document.location = "http://m.domain.tld/";
    	}
    </script>
    
    HTML:
    to redirect iPhones &amp; iPods too http://m.domain.tld/

    How can i set it to do the same with:
    Apple iPhone
    Apple iPod
    HTC Droid
    BlackBerry
    HTC Evo
    Palm
    HTC Nexus One
    and more...

    Thanks,
     
  2. shahilroyhere

    shahilroyhere Well-Known Member

    Messages:
    189
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #2
    What you have to do is to get the list of the "user agent" for the phone you want to redirect, as you have for "iphone" and "ipod". Like for Blackberry it is "blackberry" and put in the code as - navigator.userAgent.indexOf('blackberry') or navigator.userAgent.indexOf('android'). This will serve the job.
     
    shahilroyhere, Jun 3, 2010 IP