I came across a useful snippet of code that I wanted to pass on and post about. It detects whether the person viewing your website is on a iPhone or computer. If they are on a iPhone, you can redirect them to a iPhone version website or just to another page, its up to you. If they are on the computer it doesn’t redirect them and they go on as normal. Its just some simple javascript, and if you want to use it just change the “document.location” value to the url you want them redirected.
1 2 3 4 5 | <script type="text/javascript">// <![CDATA[ if ((navigator.userAgent.indexOf('/iPhone/i') != -1) || (navigator.userAgent.indexOf('/iPod/i') != -1)) { document.location = "http://www.scottrockers.com/iphone.html"; } // ]]></script> |
Cya
Tags: Detection, Development, iPhone












Just know that iPhone users hate these redirects. Other than flash, our browsers can handle just abou anything you throw at us. These redirects are pointless and annoying as hell. If you must do this, make sure we’re redirected to the iPhone version of the page we were trying to reach, not the home page, and give us a link to the full version.
Thats a good point, thanks for sharing. I am still in the process of making my homepage’s iphone version.
[...] I had posted before, How to Detect iPhone and Redirect to iPhone Version Website, really you should use the same website for both the iPod and iPhone since they seem to have the [...]
[...] goes to Scottrockers for the code snippet that actually detects what browser your [...]