Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #2
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Obviously, having been looking for hours without sucess, I finally find a script that seems to work.... minutes after posting this question.

    sorry!

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •