I always wanted to implement mac.pcbeta.com's skin function. Recently, I wrote a javascript code to save the skin name set by the user to localstorage. Every time I refresh the page, I call the field stored in localstorage, then reference the CSS file contained in the new skin according to the field .... I always wanted to implement mac.pcbeta.com's skin function.
Recently, I wrote a javascript code to save the skin name set by the user to localstorage. Every time I refresh the page, I call the field stored in localstorage, reference the CSS file contained in the new skin based on the field.
However, after writing the script, I found that, even though it can be implemented, the user needs to execute this script every time during refresh. Will it consume a lot of resources?
In fact, resource consumption is a trivial matter. The most important thing is that before the script is run, the webpage skin is the default one, and no new CSS files are introduced, but the webpage interface changes only after the script is executed.
In this way, each time you refresh the page, a highlighted white screen will appear. (The default skin is white, and the skin is set to another color), very uncomfortable.
So how does mac.pcbeta.com implement it?
I see that every time they change their skin, they will refresh the page and submit one? Styleid = 34. Then the server obtains this styleid and inserts it with the backend script? How to implement it? You must specify the visitor's skin.
Reply content:
I always wanted to implement mac.pcbeta.com's skin function.
Recently, I wrote a javascript code to save the skin name set by the user to localstorage. Every time I refresh the page, I call the field stored in localstorage, reference the CSS file contained in the new skin based on the field.
However, after writing the script, I found that, even though it can be implemented, the user needs to execute this script every time during refresh. Will it consume a lot of resources?
In fact, resource consumption is a trivial matter. The most important thing is that before the script is run, the webpage skin is the default one, and no new CSS files are introduced, but the webpage interface changes only after the script is executed.
In this way, each time you refresh the page, a highlighted white screen will appear. (The default skin is white, and the skin is set to another color), very uncomfortable.
So how does mac.pcbeta.com implement it?
I see that every time they change their skin, they will refresh the page and submit one? Styleid = 34. Then the server obtains this styleid and inserts it with the backend script? How to implement it? You must specify the visitor's skin.
You can write it like this
if styleid="black"
elseif styleid="red"
else
Or
styleid = isset(styleid) ? styleid : 'common';
However, mac.pcbeta.com also needs to jump pages .. Some browsers will also be white ..
Capture this website,
1. Run index. php. get parameter styleid = 29
2. Get the specified js and css and corresponding images.
The page is refreshed, that is, the parameter judgment in the index. php file. The parameter corresponds to different css and js variables.