In addition to the memory function, you can also set the retention time for this website style switch. For example, the default style sheet is automatically restored after 5-180 days. Style table connection, set three styles, and write the image background you want to change to the style table.
The Code is as follows:
The first is the default style table.
Script -- Author: dynamicdrive.com
Protocol of use: http://www.dynamicdrive.com/notice.htm
The Code is as follows:
// Style Sheet Switcher version 1.0 Nov 9th, 2005
// Author: Dynamic Drive: http://www.dynamicdrive.com
// Usage terms: http://www.dynamicdrive.com/notice.htm
Function getCookie (Name ){
Var re = new RegExp (Name + "= [^;] +", "I"); // construct RE to search for target name/value pair
If (document. cookie. match (re) // if cookie found
Return document. cookie. match (re) [0]. split ("=") [1] // return its value
Return null
}
Function setCookie (name, value, days ){
Var expireDate = new Date ()
// Set "expstring" to either future or past date, to set or delete cookie, respectively
Var expstring = (typeof days! = "Undefined ")? ExpireDate. setDate (expireDate. getDate () + parseInt (days): expireDate. setDate (expireDate. getDate ()-5)
Document. cookie = name + "=" + value + "; expires =" + expireDate. toGMTString () + "; path = /";
}
Function deleteCookie (name ){
SetCookie (name, "moot ")
}
Function setStylesheet (title ){
Var I, cacheobj
For (I = 0; (cacheobj = document. getElementsByTagName ("link") [I]); I ++ ){
If (cacheobj. getAttribute ("rel"). indexOf ("style ")! =-1 & cacheobj. getAttribute ("title ")){
Cacheobj. disabled = true
If (cacheobj. getAttribute ("title") = title)
Cacheobj. disabled = false // enable chosen style sheet
}
}
}
Function chooseStyle (styletitle, days ){
If (document. getElementById ){
SetStylesheet (styletitle)
SetCookie ("mysheet", styletitle, days)
}
}
Var selectedtitle = getCookie ("mysheet ")
If (document. getElementById & selectedtitle! = Null) // load user chosen style sheet if there is one stored
SetStylesheet (selectedtitle)
Call Method
The Code is as follows:
Default Style
Orange Style
Blue
Note: The title content should be changed to the name of your style sheet. Here, it is set to 5 days.