css| Page | page
1. Styleswitcher.js
function Setactivestylesheet (title) {
var i, a, main;
for (i=0; (A = document.getElementsByTagName ("link") [i]); i++) {
if (A.getattribute ("rel"). IndexOf ("style")!=-1 && a.getattribute ("title") {
A.disabled = true;
if (A.getattribute ("title") = = A.disabled = false;
}
}
}
function Getactivestylesheet () {
var i, A;
for (i=0; (A = document.getElementsByTagName ("link") [i]); i++) {
if (A.getattribute ("rel"). IndexOf ("style")!=-1 && a.getattribute ("title") &&!a.disabled) return A.getattribute ("title");
}
return null;
}
function Getpreferredstylesheet () {
var i, A;
for (i=0; (A = document.getElementsByTagName ("link") [i]); i++) {
if (A.getattribute ("rel"). IndexOf ("style")!=-1
&& A.getattribute ("rel"). IndexOf ("alt") = = 1
&& A.getattribute ("title")
) return A.getattribute ("title");
}
return null;
}
function Createcookie (name,value,days) {
if (days) {
var date = new Date ();
Date.settime (Date.gettime () + (days*24*60*60*1000));
var expires = "; Expires= "+date.togmtstring ();
}
else expires = "";
Document.cookie = name+ "=" +value+expires+ "; path=/";
}
function Readcookie (name) {
var Nameeq = name + "=";
var ca = Document.cookie.split (';');
for (Var i=0;i < ca.length;i++) {
var c = Ca[i];
while (C.charat (0) = = ') c = c.substring (1,c.length);
if (C.indexof (nameeq) = = 0) return c.substring (nameeq.length,c.length);
}
return null;
}
Window.onload = function (e) {
var cookie = Readcookie ("style");
var title = cookie? Cookie:getpreferredstylesheet ();
Setactivestylesheet (title);
}
Window.onunload = function (e) {
var title = Getactivestylesheet ();
Createcookie ("style", title, 365);
}
var cookie = Readcookie ("style");
var title = cookie? Cookie:getpreferredstylesheet ();
Setactivestylesheet (title);
2, CSS calls:
CODE:
//Default style this call
//other styles such calls
...
3, JS call:
CODE:
4, the realization of the choice of style:
Written in the body of the page
CODE:
> Default Style
> Style one
> Style two