I'm trying to switch my css stylesheets depending on the time. One during the day, and one during the night. I'm a newbie when it comes to java, but i've been reading alot on javascript and have generated some code that should let this work. I tried it, of course, it doesn't work.
I tried placing the code in the header, then I tried placing it directly after the tag.But that didn't work either.
The the css stylesheet works by itself, but doesn't work at all when used in the script. This leads me to believe that it's the script that is not right. Maybe I wrote it wrong?
Here is the javascript code:
<script language="JavaScript">
var d=new Date();
var twi_am_start = 4;
var twi_am_end = 5;
var twi_pm_start = 17;
var twi_pm_end = 18;
if (d.getHours() < twi_am_start || d.getHours() > twi_pm_end)
document.write('<link rel="stylesheet" href="http://itsnotch.com/tumblr/files/nighttime.css" type="text/css">');
else if (d.getHours() > twi_am_end && d.getHours() < twi_pm_start )
document.write('<link rel="stylesheet" href="http://itsnotch.com/tumblr/files/daytime.css" type="text/css">');
else
document.write('<link rel="stylesheet" href="http://itsnotch.com/tumblr/files/nighttime.css" type="text/css">');
</script>