View Full Version : Can I set CSS to a timer that will exchange itself with another .css file?
carnivalcat
09-04-2007, 09:51 PM
For my website I would like to have a night and day version. Depending on when you visited the site depended on which CSS showed. I know there are ways where you can manually choose which CSS is showed on your site, but I would like this to be completely automatic.
I have no idea how I am going to go about doing this. I would at least like to know if anyone has done this, has seen this done anywhere, or has even heard of such an idea? If anyone has an answer to this I would be absolutely greatful!
thetestingsite
09-04-2007, 10:06 PM
I've never seen; nor heard of it being, done before, but the idea should be easy enough to do. It just depends on if you want to use Javascript or a server side (PHP, ASP, etc) language to accomplish it. If you wanted to use PHP, the basic idea would be something like this (Placed between the head tags of the document:
<?php
if (date('H') >= '08' && date('H') <= '19' ) { //if between the hours of 8am and 7pm, show day css
?>
<link rel="stylesheet" href="day.css" type="text/css">
<?php
}
else {
?>
<link rel="stylesheet" href="night.css" type="text/css">
<?php
}
?>
Not sure how you would accomplish using Javascript, but I do know that it can be done.
Hope this helps.
shagura
09-05-2007, 08:43 AM
I have seen it done by a guy who took a photo out of his studio windows for a few times a day and then had his css file change depending on the time of day so people knew what time it was at his location. I hope that makes sense, I'm not the best person for explaining what I'm thinking!
Anyway, I couldn't find it for you to ask him about, but instead found exactly what your after, I think:
http://sonspring.com/journal/time-sensitive-css
codeexploiter
09-05-2007, 09:17 AM
The idea seems to be interesting but have to address one more thing for example if a user opens the page in the day session and closes only at night, in this case have to change the day session CSS to night session CSS automatically.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.