Easiest way to redirect your website to iPhone/iPod Touch/iPad Version

Recently I had to redirect one of the website to its iPhone version, I quickly googled, there are dozens of sites which tell in dozens of ways for doing it. However, I wasn’t very impressed by any, so came up with my own end thing.
There are few ways, mainly you either use JavaScript or php.

I will go with JavaScript, since not all sites are php, and they can be handled more easily.

You can add the below JavaScript inside the of your website to redirect it to its iPhone version.

{code type=HTML}<script language=javascript>
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
location.replace(“iPhone/iPod_Version”);
}
</script>{/code}
Of course replace iPhone/iPod_Version with the URL of iPhone/iPod Touch version.

You can also add another conditional for iPad, which makes it.

{code type=HTML}<script language=javascript>
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
location.replace(“iPhone/iPod_Version”);
}
else if(navigator.userAgent.match(/iPad/i))
{
location.replace(“iPad_Version”);
}
</script>{/code}

In most cases iPad Version will be different from iPod/iPhone version(because of width). In case they are all the same, use

{code type=HTML}<script language=javascript>
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i)))
{
location.replace(“iPhone/iPad/iPod_Version”);
}
</script>{/code}

Running website on full screen(Available in iOS 2.1 and later)

If you will like your website to run on full screen, you can additionally add the below to header

{code type=HTML}

{/code}

The content=”yes” makes it run on full screen, you can always toggle this.

Disabling automatic detection of phone numbers(Available in iOS 1.0 and later)

By default Safari browser converts phone numbers like string into a link that calls the number.

{code type=HTML}

{/code}

By using content=”telephone=no” you are disabling this feature, you can toogle this too.

There are few more additional tags, you can check them out here .
Hope this helps you.

  • Seeu

    thank you!

  • Irulappan

    please any one give the page flow script for iPad..

  • Irulappan

    please any one give the page flow script for iPad..

  • Alexxx

    Does this has to go int he head or body, i'm quite a newbie xD

  • Imad

    Thank you very much.

  • thank you!! awesome!!

  • Just came for searching this exact code. One of my clients used this same code as a comment and I think I have solved his problem.

    Thank you for placing few more funky codes too.

    Best Wishes,

    Shyam.