Sunday, March 16, 2008

Client Side iPhone / iPod Touch Browser Redirect

If layer 7 redirection from hardware based solutions isn't quite available in your enterprise, or perhaps the entire CSS3 standard hasn't completely made it into your long term memory yet there is a very easy way to redirect iPhone & iPod Touch users.

While several of our clients have experience varying levels of success, small to mid-sized solutions may benefit from a simple inline javascript redirect.

Example:

<script language=javascript>

<!--

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))

{

location.replace("http://TYPE_YOUR_URL_HERE");

}

-->

</script>




Those who are better versed in conditional CSS, will find that the iPhone
and iPod Touch react very favorably to a CSS that is optimized to the
specifications referenced by Apple in the developer documentation on their
site (Apple Developer Connection Guides).


-Robert Zullo

6 comments:

Unknown said...

Very nice it works

Gil
http://www.amorelectric.com
310-699-9444

pipicoms said...

Indeed it works! Thanks..

Unknown said...
This comment has been removed by the author.
Abby said...

Hi, What is the best place to put the javascript?

Abby Eagle

Wayne said...
This comment has been removed by the author.
Wayne said...

thanks you sooooooooo much