Results 1 to 7 of 7

Thread: Banner Rotator on Timing

  1. #1
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Banner Rotator on Timing

    Does anyone have a java script that I can put three pictures in it and have picture number one come up at 7:00 Am till 12:00 PM and then and then have picture number two come in at 12:01 PM till 6:30 PM and then have picture three come in at 6:31 PM till 6:59 AM the next day. Is this possiable?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,070
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <script type="text/javascript">
    (function(){
    var ims=['morning.jpg', 'afternoon.jpg', 'evening.jpg'];
    var d=new Date(), h=d.getHours(), m=h*60+d.getMinutes();
    var im_num=m>=7*60&&m<12*60? 0 : m>=12*60&&m<18*60+30? 1 : 2;
    document.write('<img src="'+ims[im_num]+'">');
    })();
    </script>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So is the above script already for me including the times that I have listed. And if I have to change the times how would I do so? Thanks for the script anyways.

  4. #4
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Quote Originally Posted by jandjweb View Post
    So is the above script already for me including the times that I have listed. And if I have to change the times how would I do so? Thanks for the script anyways.
    it looks like its all ready made.. the only thing you would need to change is the url to the image
    Quote Originally Posted by John
    var ims=['morning.jpg', 'afternoon.jpg', 'evening.jpg'];

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,070
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    That's right boogyman. To make it clearer (in the script):

    7*60 is 7:00am

    12*60 is 12:00 noon

    18*60+30 is 6:30pm
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So how do I change the timing code if I have to change the times that
    the pictures appear?

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,070
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    The timing is set here:

    Code:
    var im_num=m>=7*60&&m<12*60? 0 : m>=12*60&&m<18*60+30? 1 : 2;
    In English - If the time is greater than or equal to 7:00am and less than 12:00 noon, show image #0, else if the time is greater than or equal to 12:00 noon and less than 6:30pm, show image #1, else show image #2.

    That taken with my previous explanation of how the times are written:

    7*60 is 7:00am

    12*60 is 12:00 noon

    18*60+30 is 6:30pm
    You should be able to figure it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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