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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Day & Night Banner rotate

    Hi,
    Can some please Help.
    I need a banner to change between 2 images for day and nighttime. Banner can change at 6 in the morning and 6 at night.
    There is a lot of scripts on the net, but they can only be set for a couple of seconds or minutes.
    Thanks
    Chanse Turner

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Hey,

    add this snippet of code into the head of your html page:
    Code:
    <script language="JavaScript">
    <!--
    
    function changeBanner(){
    
    t = new Date();
    hour = t.getHours();
    if (hour >= 18 || hour < 6) {
    	document.getElementById("banner").src = "night.gif";
    }
    }
    
    
    //-->
    </script>
    Then add onLoad="changeBanner();" to your body tag.

    The img tag should have the id="banner" and the src of the day image.

    Hope this helps
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Badman3k,
    Thanks for the reply.
    I have tried this, but it doen't seem to work.
    Here is part of the source code.

    <META NAME="ROBOTS" CONTENT="INDEX, FOLLOW">
    <META NAME="REVISIT-AFTER" CONTENT="5 DAYS">
    <META NAME="RATING" CONTENT="GENERAL">

    <script language="JavaScript">
    <!--
    function changeBanner(){
    t = new Date();
    hour = t.getHours();
    if (hour >= 18 || hour < 6) {
    document.getElementById("banner").src = "themes/Aeolus/images/night.jpg";
    }
    }
    //-->
    </script>

    </head>

    <body onLoad="changeBanner();" background="themes/Aeolus/images/bg_main.gif" bgcolor="#000000" text="#FFFFCC" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">

    <table class="bodyline" width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td align="center" valign="top">
    <table width="99%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td align="center" width="100%" height="110" background="themes/Aeolus/images/day.jpg" valign="top" id="banner">&nbsp;</td>
    </tr>
    </table>
    Maybe it's something I've done wrong.
    As you can see, the "day.jpg" is the background of a cell in a table.

    Just have a look and see if I've got all the code in the right places.

    Thanks.
    Chanse Turner.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Ahh I didn't realise it was the background to a cell.

    Since this is the case, try replacing the line:

    document.getElementById("banner").src = "themes/Aeolus/images/night.jpg";

    with:

    document.getElementById("banner").background = "themes/Aeolus/images/night.jpg";

    and see if that works.
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #5
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Badman3k,
    Thanks man you're a STAR...
    It's working now!!
    I have added you to my ICQ list, I hope you've received the request from ICQ.
    Thanks again.
    Chanse Turner.


  •  

    Posting Permissions

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