Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View full website, not mobile version on iPhone

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.

like image 786
Rya Avatar asked Nov 15 '10 04:11

Rya


People also ask

How do I switch from full site to mobile?

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.


1 Answers

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.

like image 155
Surreal Dreams Avatar answered Sep 23 '22 02:09

Surreal Dreams