JS平滑切换CSS文件_浏览器特效

模板酷站
  •       3/5
  •       1
  •       2
  •       3
  •       4
  •       5
查看演示效果

      织梦DedeCMS视频教程买空间 租服务器 选网硕互联! 无忧站长工具,百度权重一键全查!

      利用JavaScript平滑切换CSS文件,可以在你的不同颜色风格、界面样式的CSS文件间切换,快速改变你的网页风格,你事先应准备好你的CSS文件,以免看不到效果。其实已经有很多类似功能的代码,但感觉这一个好像代码更少一些,为什么要用复杂的呢?

      <html> <head> <title>在不同CSS文件之间平滑切换</title> <link rel="stylesheet" href="style_1.css"> <link rel="stylesheet" href="style_2.css"> <link rel="stylesheet" href="style_3.css"> <link rel="stylesheet" href="style_1.css"> <script language="JavaScript"> <!-- var doAlerts=false; function changeSheets(whichSheet){ whichSheet=whichSheet-1; if(document.styleSheets){ var c = document.styleSheets.length; if (doAlerts) alert('Change to Style '+(whichSheet+1)); for(var i=0;i<c;i++){ if(i!=whichSheet){ document.styleSheets[i].disabled=true; }else{ document.styleSheets[i].disabled=false; } } } } //--> </script> </head> <body> <a href="JavaScript:changeSheets(1)">Style One</a> <a href="JavaScript:changeSheets(2)">Style Two</a> <a href="JavaScript:changeSheets(3)">Style Three</a> </body> </html>