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:

  1. Very nice it works

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

    ReplyDelete
  2. Indeed it works! Thanks..

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hi, What is the best place to put the javascript?

    Abby Eagle

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. thanks you sooooooooo much

    ReplyDelete