Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to forward my viewers on my site to a different place if they are using an iPhone. Is there a way to do that using iWeb?

share|improve this question
add comment

4 Answers

You can use this script in the HEAD section of your index file.

<script type="text/javascript">
        var agent=navigator.userAgent.toLowerCase();
        var is_iphone = (agent.indexOf('iphone')!=-1);
        if (is_iphone) { window.location ="http://www.yourPage.com/iphone" }
</script>

and redirect your visitor to iPhone compatible page. See an example on http://www.barisoztekin.com

share|improve this answer
add comment

Typically this is done server side by evaluating the User Agent that is passed with the HTTP request. I believe iWeb just publishes static pages and doesn't support dynamic content. In that case you will probably need to resort to using JavaScript so that the redirect is performed client side.

Be careful when using this approach though as it has the potential to create a poor user experience. It would be best to establish a way to allow the user to view the page if they really want to. Typically this is done with a cookie if the user selects that they want the 'normal' site rather than the 'mobile' one.

share|improve this answer
add comment

Don't.

The only reasons to ever have a separate mobile site are cheapness and laziness.

The right approach is to have your visitors all get the same content; the only thing that should change how that content is styled—and doing that doesn't need a separate site, or even a special page.

If your next question is "Can iWeb do that?," the answer is that I doubt it, because iWeb just isn't meant to be a professional web development tool. If you're looking for an alternative, I recommend TextWrangler—it's both better and cheaper.


References:1

1 Yes, they're both me.

share|improve this answer
1  
Thank you for your answer. But I wasn't looking for opinions on IF it should be done; but how it CAN done. -1 –  Linuxmint Jan 1 '11 at 3:31
5  
I appreciate this doesn't answer the question, but it is worth pointing out to less experienced web developers. If you do have a separate mobile site, at least have an option to view the normal site. It is extremely frustrating when poorly designed web sites prevent access to information because the insist on using a crappy mobile version of the site when the iPhone can handle viewing the normal site just fine. –  g . Jan 1 '11 at 15:06
    
@Linuxmint - No one will be able to tell you how to do it with iWeb, as iWeb just cannot do it—it's not a real Web development tool. If you don't like that answer, that's not my problem; I was simply trying to help (a mistake I won't repeat). –  Dori Jan 2 '11 at 1:36
1  
+1 even if it does not answer the question on the title, it is very insightful and does give the best solution for the problem. –  Cawas Jan 2 '11 at 23:19
2  
As an iPhone user, when I make a Google search and click on a search result I expect to land on the page with the content I was looking for -- not some random "welcome iphone users" page. This will result in me going back to Google's results and selecting a different website. –  David Rouse Jan 3 '11 at 14:44
add comment

You can do it from the environment settings passed to a CGI or app called by the server. The HTTP_USER_AGENT field describes the client connecting to the server, and is what is often used to branch or redirect based on a particular browser.

The downside to sensing with that is it can be spoofed and/or changed in a lot of client software.

share|improve this answer
2  
To contribute: there isn't going to be an easy way to do this via iWeb. You'll have to do a 'publish' of the site to a directory on your computer and manually edit the code, adding the prerequisite checking of the user agent. Then you can separately push that folder up to the FTP for your site. –  Ryan Wersal Jan 1 '11 at 0:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.