怎么使用JavaScript每天定时更换网页调用样式表?
How to use JavaScript to regularly change the web page to call the style sheet every day? -PHP Chinese website Q&A-How to use JavaScript to regularly change the web page to call the style sheet every day? -PHP Chinese website Q&A
Let’s take a look and learn.
这段js代码通过每天在不同时段自动更换网页调用的样式表,实现更换皮肤的功能。
<script type="text/JavaScript"> <!-- function getStylesheet() { var currentTime = new Date().getHours(); if (0 <= currentTime&¤tTime < 5) { document.write("<link rel='stylesheet' href='night.css' type='text/css'>"); } if (5 <= currentTime&¤tTime < 11) { document.write("<link rel='stylesheet' href='morning.css' type='text/css'>"); } if (11 <= currentTime&¤tTime < 16) { document.write("<link rel='stylesheet' href='day.css' type='text/css'>"); } if (16 <= currentTime&¤tTime < 22) { document.write("<link rel='stylesheet' href='evening.css' type='text/css'>"); } if (22 <= currentTime&¤tTime <= 24) { document.write("<link rel='stylesheet' href='night.css' type='text/css'>"); } } getStylesheet(); --> </script> <noscript> <link href="main.css?1.1.5" rel="stylesheet" type="text/css"> </noscript>
How to use JavaScript to regularly change the web page to call the style sheet every day? -PHP Chinese website Q&A-How to use JavaScript to regularly change the web page to call the style sheet every day? -PHP Chinese website Q&A
Let’s take a look and learn.
这段js代码通过每天在不同时段自动更换网页调用的样式表,实现更换皮肤的功能。