JS Traverse page All link style and add CSS code

Source: Internet
Author: User

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>js traverse all link style on the page and add CSS code </title>
<script language= "Web Effects" type= "Text/javascript" >
function Getallsheets () {
if (!window.scriptengine && navigator.__ice_version) {
return document.stylesheets;
}
if (document.getelementsbytagname) {
var lt = document.getelementsbytagname (' link '), st = document.getElementsByTagName (' style ');
else if (document.stylesheets && document.all) {
var lt = document.all.tags (' link '), st = document.all.tags (' style ');
} else {
return [];
}
for (var x = 0, os = []; lt[x]; x + +) {
var rel = Lt[x].rel? Lt[x].rel:lt[x].getattribute? Lt[x].getattribute (' rel '): ';
if (typeof (rel) = = ' String ' && rel.tolowercase (). indexof (' style ') + 1) {
Os[os.length] = lt[x];
}
}
for (var x = 0; st[x]; x + +) {
Os[os.length] = st[x];
}
return OS;
}

function Changestyle () {
for (var x = 0, ss = Getallsheets (); ss[x]; x + +) {
for (var y = 0; y < arguments.length; y++) {
if (Ss[x].title = = Arguments[y]) {
if (ss[x].disabled = = False) {
Ss[x].disabled = true;
} else {
ss[x].disabled = false;
}
}
}
}
}

for (var x = 0, ss = Getallsheets (); ss[x]; x + +) {
if (Ss[x].title = = ' print ') {
Ss[x].disabled = true;
}
}
</script>

<body>
</body>

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.