Seniors helping seniors use computers and the internet


Mobile Design Subsite

Linking to Full Site

Here there is a catch 22 – suppose a mobile user wants to check something in the full website.  But if they are linked back to the full website it will redirect them to the mobile sub-site.  So a trick is needed to let the full website know that it has been called from the sub-site. 

There are two ways to signal between web pages (that I know of) - adding a query to the link call or setting a cookie. I started (and ended) with the query process but I also tried the cookie method when I ran into persistancy snags (of which more later).

Thus the link from the mobile page to the full site is extended from
      <a href="../index.htm">View Full Website</a>   (index.htm is the home page) to
      <a href="../index.htm?GoFull=1">View Full Website</a>
and the full site can detect this query and bypass the mobile test.

The next snag is that if the client browses to a page in the full site, and then returns to the home page, the query will NOT be set so the call drops back to the mobile site.  The solution to this is for the home page to set a session cookie called "NotMobile=1" to continue to overide the mobile test.  This worked well under tests on a computer or a tablet, where one routinely closes the browser after use (thus ending the session).  But when I started showing my site to associates on my Moto G (Android/Chrome) phone the switch to mobile frequently failed. 

It took a lot of investigation to find out why this occurred - certainly if I cleared all History in Chrome the problem did not occur (but you cannot expect other users to do this); so Chrome was retaining either the cookie or the query in its cached record of the site; not unreasonably with potentially slow data rates on mobile connections.  It turned out that it retained both bits of information, and both had to be self-clearing.  You could clear a session cookie by closing the tab and the query by closing Chrome, but again the general user would not do this.

For my final solution I changed the cookie from a session cookie to a persistant cookie with an expiry time 10 minutes into the future (this should allow for almost any browse of the full site).  For the query I reset the call to remove the query.  Also the 'View Mobile Website' button on the Home page clears the cookie immediately.

In the process I wrote a cookie test page which you can play with here.

Again the code for all this is on the JavaScript page.

Next Page - JavaScript

Copyright © Ken Curwen 2012, 2013, 2014, 2015, 2016, 2017