Created
March 7, 2017 01:59
-
-
Save alireza-saberi/a4a98534b64bdb2d6e893b2c86184c07 to your computer and use it in GitHub Desktop.
This is a simple hack that, we can tell the browser which CSS it should use during the day and which CSS it should use during the night time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script type="text/javascript"> | |
| function setTimedStylesheet(){ | |
| var theTime = new Date().getHours(); | |
| if ( 8 <= theTime && theTime < 20) { | |
| // day time | |
| document.write("<link rel='stylesheet' href='daytime.css'"); | |
| } | |
| else { | |
| // night time | |
| document.write("<link rel='stylesheet' href='timetime.css'"); | |
| } | |
| } | |
| setTimedStylesheet(); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment