Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-23-2005, 10:29 PM   PM User | #1
Tailslide
New to the CF scene

 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Tailslide is an unknown quantity at this point
Time-Related Stylesheet Switcher

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 is offline   Reply With Quote
Old 03-23-2005, 11:33 PM   PM User | #2
Tailslide
New to the CF scene

 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Tailslide is an unknown quantity at this point
Obviously, having been looking for hours without sucess, I finally find a script that seems to work.... minutes after posting this question.

sorry!
Tailslide is offline   Reply With Quote
Old 03-24-2005, 12:23 PM   PM User | #3
Tailslide
New to the CF scene

 
Join Date: Mar 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Tailslide is an unknown quantity at this point
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:

Code:
<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>
Tailslide is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:48 AM.


Advertisement
Log in to turn off these ads.