首页 > 网站 > 建站经验 > 正文

JavaScrip-t每天定时更换皮肤样式的方法

2019-11-02 14:16:50
字体:
来源:转载
供稿:网友

   本文实例讲述了JavaScript每天定时更换皮肤样式的方法。分享给大家供大家参考。具体分析如下:

  这段js代码通过每天在不同时段自动更换网页调用的样式表,实现更换皮肤的功能。

  ?

1 2 3 4 5 6 7
云盘影视网[www.aikan.tv/special/yunpanyingshi/]
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 <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" rel="stylesheet" type="text/css"> </noscript>

  希望本文所述对大家的javascript程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表