in my index.html page of my website to re-route small screen browsers to a small version of my site.
I appreciate that some mobile phone users will want to view my main site rather than my mobile version. So I wondered what code I could use that would identify a second visit from the same phone and allow it to view my main site rather than re-routing it again to the mobile site.
This way, I could simply have a link on the mobile site that says "Visit Main Site".
Any help much appreciated.

Philip M

07-17-2012, 07:19 PM

Use a cookie to detect whether the user has visited this site before.

But why not just have "Visit Main Site" as a link even on the first visit?

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

alan82

07-17-2012, 08:30 PM

Ok but I prefer to have it automatically redirect so mobiles get a fast loading page as a first option.

How do I go about using a cookie in this way?

Philip M

07-17-2012, 08:44 PM

How do I go about using a cookie in this way?

Cookies have been covered very many times in this forum. Try using the search feature.

I appreciate the help.
It occurred to me that I am forcing a second visit to the the main website when in fact the visitor may want to return to the mobile site version.
I am thinking the only way round this is to ensure the same content is on the mobile as is on the main site but kept much lighter. (very small file sizes for pictures and only css for styling (no images).
I still want that fast download experience so I will use the...

I still have the problem that if the mobile phone visitor specifically wants to visit my main index.html page, **when they click on "main site" in the indexmobile.html page, it still redirects back to indexmobile.html instead of going to index.html.

So I'm very happy with the idea that the mobile visitor is automatically directed to the indexmobile.html (nice and fast), and even happier that he is then able to visit the main site using a "main site" link on the indexmobile.html page.

The problem I am having is that the **last bit isn't working with the code i'm using above. (namely, the visitor can't get to my main site with a mobile phone).

tracknut

07-21-2012, 05:36 PM

Dunno if you're up for a bit of server side code, but I do this via allowing a parameter on the index page. For example, http://www.example.com/index.php?page=mobile, or ?page=desktop, both of which circumvent all checking for other things like screen width, and just go to the requested page. I use that in the "I'm on a mobile, but really I want to see the large site" link (and the converse on the large site page).

Dave

alan82

07-21-2012, 06:24 PM

apologies to hdewantara
Ok (as suggested by hdewantara) for my index.html page I have
I made a mistake at my end and it was all working very well now. So thank you.

Dunno if you're up for a bit of server side code
Yes I would be interested to also find out more about the server sided code.
Can you explain further how this would work?

tracknut

07-21-2012, 09:55 PM

You would do something like this, toward the top of your index file (php example):

<a href="index.php?mode=desktop">Click here for full version of site</a>

Dave

hdewantara

07-22-2012, 07:32 AM

@Alan82: You're welcome. I'm glad it works :thumbsup:
@Dave: Yes, parameter passing this way should be best handled by server side's. My oversimplified code might be problematic whenever there are other parameters to be passed as well.