Answer the question
In order to leave comments, you need to log in
How to remember that the user has chosen the desktop version and not let the mobile css work?
Colleagues, a question.
There is a mobile version of the site, it is made using css (@media handheld and @media only screen and (max-device-width: 480px))
What is the best way to organize the transition to the desktop version? In order for the user to click on the Desktop version, the desktop version was loaded for him, and further clicking on the links, he also saw the desktop version.
What is the best way to do this? Through get-parameters, cookies and so on? Maybe there are already proven solutions in the industry. I don't want to reinvent the wheel.
Here the user went to the page from the mobile phone. Mabilka automatically picked up the styles for the mobile. The mobile view is displayed.
The user wants to see the desktop version. Clicks on the link - and here, for example, we reload this page through the get-parameter and, using php, display, for example, some class that will prevent mobile styles from working or something else, it doesn’t matter.
How to remember that the user has chosen the desktop version and not let the mobile css work?
After all, he clicks on the link and mobile styles will work for him again. Carrying a get parameter? Cookies to write?
Surely there is some common solution.
Answer the question
In order to leave comments, you need to log in
Well, I don’t think that assigning a get parameter to EVERY link on the site would be the right and simple solution, don’t you think?
Set the cookie before closing the browser, and that's it.
at the bottom, put the link "full version of the site" and write the cookie on it
1. If there is no cookie with the site version, then determine it by the browser. If there is a cookie, then apply the style that is in the cookie.
2. Make a choice of mobile / css style and pass the parameter via GET (1 time is enough to pass to create cookies).
After clicking on the link if($_GET['style']=='mobile') {Loading the mobile style… creating a cookie that the user has chosen mobile}
I can show you how everything is organized on some sites.
1. On the main page or in any other place, choose:
2. Check GET and set the cookie:
3. Depending on the cookie, set the style or whatever you want.
web / mobile
if($_GET['stheme']=="html")
{
setcookie('stheme', "html");
define(HTML_STYLE,'on');
}
if($_GET['stheme']=="mobile")
{
setcookie('stheme', "mobile");
define(MOBILE_STYLE,'on');
}
I don’t know what your site is written on, but the logic is this.
Connect as In it, check for the presence of cookies, if there are no cookies, you insert @import default styles.
If there is a cookie, then insert styles for desktop or mobile only.
In which there is a definition
Although it is possible to determine in the same way at the template level what kind of browser and, depending on it, connect the necessary styles.
PS I would make one style separate for mobile phones to reduce its size as much as possible, and one full style, which will have everything.
Yes, it is more difficult to maintain, but you can include the mobile style via @import of the main one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question