Redirecting Your Website to an iPhone Website Created with iWeb
So you have a website, but you’ve also got an iPhone optimized version of the same site. How do you get your users browser to automatically detect that the user is using a mac/pc or an iphone?
The best iPhone Redirect JavScript I’ve seen. After evaluating several different way to do this I found this to the the simplest one out there. Simply past this into the page and edit the url for your iPhone enabled page:
<script>
if(navigator.userAgent.indexOf(“iPhone”) != -1)
{
window.location = “http://iphone.iwebtemplate.com”;
}
</script>
Replace http://iphone.iwebtemplate.com with your iphone website URL. Great iPhone iWeb Tempates can be found by clicking here.
I’m using a local server as a testing ground. I used your script and it works fantastically, thanks. I do have a problem and I hope you or someone can help:
I want to include a link for my full site on my mobile site, for users that do want to see the my main website as it is. The problem is that once I add that link as soon as the page loads it is of course redirected by the script back to the mobile site. How can I work around this? I’m using the latest iWeb.
Thanks!
-George
Hi – I would suggest creating a ‘mirror’ site on either a subdomain or in a new folder and redirecting to this – do not include the redirect code into these pages. That should do the trick!