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.
i pu this code on dreamweaver and it tells me there is a syntaxis mistake is it becouse it thinks it is html _?
I cannot get this to work. Why??? Just pasted the code into the head tag of the page, then loaded it with my iPhone. It does not detect. Is there something else I need to do??
http://metasteve.com
your script doesnt work
I found an iPad detect and redirect here http://www.combsconsulting.com/java-script-detect-ipad/index.html.
Not working. I was so very hopeful!!!
You can also check to see if the reported platform is iPhone or iPod:
if (navigator.platform == “iPhone” || navigator.platform == “iPod”)
{
window.location.href = “iphone-version.html”;
}
it works if you remove the “hide” tags before and after, the