I have a script that detects whether you're an iPhone user or not and redirects to a more iPhone friendly page.
<script type="text/javascript">
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{
location.replace("http://domain.com/iphone/");
}
</script>
This works great but has one problem. It is convention to offer the user the ability to view the full web page. However, if I link to the root, obviously the redirect is going to send them to the mobile version!
Any ideas on how to include if click on the link from /iphone/
, they can go to /
and stay there.
If you are using Google Chrome browser on Android Phone or Tablet, you can go back to Mobile Version of website by tapping on 3-dots icon and unchecking the little box next to Request Desktop Site option.
When the user arrives, determine their browser type - mobile or full - and set a cookie with this value. Use this cookie value to decide what version of the site to display. AS you mention, offer a link to the "full" site to the mobile users, but if they click it, run a quick script to update the cookie to the "full" value and then redirect them to the full site. Their cookie is now set for the full site, so they won't get bounced back to the mobile site.
Now, if cookie are a problem, you could use something like PHP to set a session values to maintain the full/mobile status of the session, but that's probably getting beyond the scope of the original question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With