...

View Full Version : Time-Related Stylesheet Switcher



Tailslide
03-23-2005, 11:29 PM
Hi there - hoping you can help me.

I've had a user-operated Stylesheet Switcher (the ALA one) operating on my site for a while - but I'd really like to get a scipt that would switch the stylesheets according to the time of day - can anyone help?

Thanks in advance!

Tailslide
03-24-2005, 12:33 AM
Obviously, having been looking for hours without sucess, I finally find a script that seems to work.... minutes after posting this question.

sorry!

Tailslide
03-24-2005, 01:23 PM
Well it all worked nicely in my local browser - but when I loaded it up to the web and had a look at it in BrowserCam, most of the screenshots showed the last stylesheet in the list was being used - plus the whole page was blank in safari- any ideas about what I've done wrong?

The code I used was:



<link id="default" rel="stylesheet" type ="text/css" href="lbpstyle.css"/>

<script type="text/javascript">

var daycontent=new Array();

daycontent[0]="morningstyle.css";
daycontent[1]="lbpstyle.css";
daycontent[2]="nightstyle.css";
daycontent[3]="nightstyle.css";

var my_date = new Date();
var my_hour = my_date.getHours();

if(my_hour>=6 &&my_hour<12) {
my_hour=0;
}
else {
if(my_hour>=12 &&my_hour<18) {
my_hour=1;
}
else {
if(my_hour>=18 &&my_hour<=23) {
my_hour=2;
}
else {
if(my_hour>=0 &&my_hour<6) {
my_hour=3;
}
}
}
}

var am_pm=my_hour;
document.getElementById("default").href=daycontent[am_pm];

</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum