Web CSS realizes whole station style switch _javascript skill

Source: Internet
Author: User

Directly paste Code

Copy Code code as follows:

Take element with two $ is to not conflict with jquery
function $$ (s) {
return document.getElementById (s);
}
function Setblue () {
Write Cookies First
Writecookie ("Iscssstyle", "Css/crm_blue.css", 365, true);
Set up a new CSS file
$$ ("Maincss"). href = "Css/crm_blue.css";
Take the main frames page and reset the CSS file
var childobj = window.parent.document.getElementById ("Managermain"). Contentwindow;
Childobj.document.getElementById ("Maincss"). href = "Css/crm_blue.css";
}
function Setgreen () {
Write Cookies First
Writecookie ("Iscssstyle", "Css/crm.css", 365, true);
Set up a new CSS file
$$ (' Maincss '). href = "Css/crm.css";
Take the main frames page and reset the CSS file
var childobj = window.parent.document.getElementById ("Managermain"). Contentwindow;
Childobj.document.getElementById ("Maincss"). href = "Css/crm.css";
}
function Setgray () {
Write Cookies First
Writecookie ("Iscssstyle", "Css/crm_gray.css", 365, true);
Set up a new CSS file
$$ (' Maincss '). href = "Css/crm_gray.css";
Take the main frames page and reset the CSS file
var childobj = window.parent.document.getElementById ("Managermain"). Contentwindow;
Childobj.document.getElementById ("Maincss"). href = "Css/crm_gray.css";
}


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") = = title)
a.disabled = false;
//        }
//    }
$$ ("Maincss"). attr ("href", "css/crm_blue.css");
$$ (' Maincss '). href = "Css/crm_blue.css";
To set a file for CSS
$$ (' Maincss '). href = title;
}
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;
var cssfile = $$ (' maincss '). href;
alert (cssfile);
return cssfile;
}
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;
var cssfile = $$ (' maincss '). href;
alert (cssfile);
return cssfile;
}
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 Writecookie (name, value, hours, ESCP) {
var expire = "";
if (hours!= null) {
expire = new Date (new Date ()). GetTime () + hours * 3600000);
expire = "; Expires= "+ expire.togmtstring ();
}
if (ESCP = = "True") {
Document.cookie = name + "=" + value + expire;
} else {
Document.cookie = name + "=" + Escape (value) + expire;
}
}


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;
}
$ (document). Ready (function () {


var title = Readcookie ("Iscssstyle");
var title = "Css/crm_blue.css";


if (title!= null && title!= "undefined") {
Setactivestylesheet (title);
//}
});

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.