Skip to content

24 ways to impress your friends

Vote up?

PHIL SORRELL

Great article Sarah – really gives an insight into the iPhone specific features that you can access.

There seems to be some concerns here about the redirection.

Whilst I probably would not use Javascript for the redirection, I was always under the impression that Javascript in the <head> ran before the remaining content is loaded (hence why you need to use onload if your javascript is modifying the dom structure of your page) – whilst other styles and scripts will still be downloaded, none of the content should be before the redirect kicks in.

As far as how whether to redirect to a single page or do a complete redirect, this depends entirely on what you want to achieve. I agree completely that if you wanted an iPhone version of a blog then you would probably want to do a full redirect, but Sarah’s code can easily be modified with:

header(‘Location: http://mobile.yoursitehere.com’ . $_SERVER[‘REQUEST_URI’] . $_SERVER[‘QUERY_STRING’]);

However it is equally possible that for other uses your iPhone specific version will be different to your web version, especially in the example Sarah gives as replicating an iPhone app – in this case it may be appropriate to redirect only to the homepage to provide a different user experience.

.htaccess can obviously achieve the same thing, but will not help if you have a windows server.