js遍曆頁面所有link style並增加css代碼

來源:互聯網
上載者:User

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>js遍曆頁面所有link style並增加css代碼</title>
 <script language="網頁特效" 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>
</head>

<body>
</body>
</html>

相關文章

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.