Home > Web Front-end > JS Tutorial > body text

JavaScript method to change skin style regularly every day_javascript skills

WBOY
Release: 2016-05-16 15:51:55
Original
1235 people have browsed it

The example in this article describes how to use JavaScript to change skin styles regularly every day. Share it with everyone for your reference. The specific analysis is as follows:

This js code realizes the function of changing the skin by automatically changing the style sheet called by the web page at different times every day.

<script type="text/JavaScript">
<!--
function getStylesheet() {
   var currentTime = new Date().getHours();
   if (0 <= currentTime&&currentTime < 5) {
    document.write("<link rel='stylesheet' href='night.css' type='text/css'>");
   }
   if (5 <= currentTime&&currentTime < 11) {
    document.write("<link rel='stylesheet' href='morning.css' type='text/css'>");
   }
   if (11 <= currentTime&&currentTime < 16) {
    document.write("<link rel='stylesheet' href='day.css' type='text/css'>");
   }
   if (16 <= currentTime&&currentTime < 22) {
    document.write("<link rel='stylesheet' href='evening.css' type='text/css'>");
   }
   if (22 <= currentTime&&currentTime <= 24) {
    document.write("<link rel='stylesheet' href='night.css' type='text/css'>");
   }
}
getStylesheet();
-->
</script>
<noscript>
<link href="main.css" rel="stylesheet" type="text/css">
</noscript>

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!