ExtJs2.0 Learning Series (--EXTJS) Change skin

Source: Internet
Author: User
Tags split

ExtJS's default skin looks good, but we can also change styles to switch other skins.

1. Add other CSS files directly to change skin.

Skin file: Xtheme-olive.zip download

Unzip the skin file and copy the CSS file (such as XTHEME-OLIVE.CSS) to the ExtJS resources directory in the CSS folder:

Unzip the skin file and copy the contents of the corresponding image folder (such as Olive) into the ExtJS resources directory under Images folder

Set the CSS file as follows:

In fact, in the original based on the addition of a xtheme-olive.css file.

Effect Chart:

2. With cookies to achieve the website skin Change

Our goal:

/*
Users can choose their own style, when the next user opened the site (within the validity of the cookie), automatically read cookies, display the previous choice of hobby style!
*/

Our principle:

Key points
1.document.getelementsbytagname ("link") [1].href//Gets or sets the href value of the second CSS file
2.var date=new Date ()/day
Date.settime (Date.gettime () +30*24*3066*1000);//30 days after the date
Document.cookie= "css=" +name+ "expires=" +date.togmtstring ()//Set expired cookies after 30 days (name is CSS)
3.var cookiesarr=document.cookie.split (";");
var css;
for (Var i=0;i<cookiesarr.length;i++)
{
var arr=cookiesarr[i].split ("=");
if (arr[0]== "CSS")
{
CSS=ARR[1];
Break
}
}
This code is to obtain cookies in the name of the desired CSS, and save in the variable CSS

Related Article

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.