Detect iPhone/iPod Touch User Coming To Your Site
Jun 4th, 2008 by Leonard Ghazarian |
Email This Post
|
Print This Post
Here is a quick way to detect users coming to your site using an iPhone/iPod Touch and to redirect them to your MOBILE version of your site.
The script should go between the HEAD section of your page. Just replace iphone-version.html with the URL of your MOBILE version of your site.
<script language=javascript>
<!–
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
location.replace("iphone-version.html");
}
–>
</script>
Once you got that going and your MOBILE version of your site is up, don’t forget to customize your Web Clip icon (Website’s iPhone Icon). Watch this video for the how-to.

rather than just catering for iphones, if you use handsetdetection.com or a similar service, you can detect most of the handsets / pda’s in the market and display the correct view for each.