JavaScript-about the website for skin-changing features, who can tell under mac.pcbeta.com its principle of skin change?

Source: Internet
Author: User
Always wanted to achieve mac.pcbeta.com skin function.
Recently wrote a JS to implement, the user set the name of the skin in localstorage, each time you refresh the page to call the field saved in Localstorage, and then reference the new skin according to the field contains the CSS file.
But after the completion of the discovery, although it can be achieved, but every time users refresh the need to execute this script, will be very resource-intensive?
In fact, the consumption of resources or small, the most important thing is that before the script runs, the skin of the Web page is the first default, not the introduction of new CSS files, but after the implementation of the Web interface changes.

In this way, every time you refresh the page, there will be a flash of white screen. (The default skin is white, set to use the skin for other colors), very uncomfortable.

So, mac.pcbeta.com, how did they make it?

I see them refresh the page every time they change their skin, and submit a styleid=34, and then the server gets to this styleid and then inserts it with the backend script? How is it to be implemented specifically? Also specify the skin that you know which guest set

Reply content:

Always wanted to achieve mac.pcbeta.com skin function.
Recently wrote a JS to implement, the user set the name of the skin in localstorage, each time you refresh the page to call the field saved in Localstorage, and then reference the new skin according to the field contains the CSS file.
But after the completion of the discovery, although it can be achieved, but every time users refresh the need to execute this script, will be very resource-intensive?
In fact, the consumption of resources or small, the most important thing is that before the script runs, the skin of the Web page is the first default, not the introduction of new CSS files, but after the implementation of the Web interface changes.

In this way, every time you refresh the page, there will be a flash of white screen. (The default skin is white, set to use the skin for other colors), very uncomfortable.

So, mac.pcbeta.com, how did they make it?

I see them refresh the page every time they change their skin, and submit a styleid=34, and then the server gets to this styleid and then inserts it with the backend script? How is it to be implemented specifically? Also specify the skin that you know which guest set

You can write it like this

If styleid= "Black"
 
   elseif styleid= "Red"
 
   Else
 
  

Or so

Styleid = Isset (Styleid)? Styleid: ' Common ';
 
  

However, Mac.pcbeta.com also want to jump page ah. In some browsers will also be white.

Grab the site and remove it,
1. Run index.php, get parameter Styleid = 29
2. Get the specified JS and CSS and the corresponding picture.

It also refreshes the page. is to judge the parameters in a index.php. Parameters correspond to different CSS and JS variables.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.