every hour another background image

Discussion in 'Javascript' started by Jomba, Aug 13, 2008.

  1. Jomba

    Jomba Guest

    Hi everyone,

    In folder image i have 24 pictures, and i would like to have some
    javascript that will every hour put another picture as background
    image.

    I would like to do that on this page www.karta-zagreba.com

    Tnx everyone!
     
    Jomba, Aug 13, 2008
    #1
    1. Advertising

  2. Jomba wrote:

    > In folder image i have 24 pictures, and i would like to have some
    > javascript that will every hour put another picture as background
    > image.


    document.body.style.backgroundImage = 'url('
    + (new Date()).getHours()
    + '.jpg)';

    from 00:00 to 00:59 -> 0.jpg
    from 01:00 to 01:59 -> 1.jpg
    from 02:00 to 02:59 -> 2.jpg
    ....
    from 23:00 to 23:59 -> 23.jpg

    This code is preferrably placed in an onLoad-event of the body-tag.

    Hope this helps,

    --
    Bart
     
    Bart Van der Donck, Aug 13, 2008
    #2
    1. Advertising

  3. In comp.lang.javascript message <51dac5b5-f31f-4938-9552-1712a54b21e6@z7
    2g2000hsb.googlegroups.com>, Tue, 12 Aug 2008 23:56:59, Jomba
    <> posted:
    >
    >In folder image i have 24 pictures, and i would like to have some
    >javascript that will every hour put another picture as background
    >image.


    Do you mean for the image to be loaded only with the page, and remain as
    long as the page remains displayed, or do you want a new image to be
    fetched each hour, in the manner of a clock? To get a good answer, a
    good question is required.

    It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

    --
    (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9 Sf3
    news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
     
    Dr J R Stockton, Aug 13, 2008
    #3
  4. Jomba

    Ivan Guest

    sory, my english is not very well, so I ask only short Q :)

    When someone open page, image remain as long as the page displayed.



    "Dr J R Stockton" <> je napisao u poruci interesnoj
    grupi:...
    > In comp.lang.javascript message <51dac5b5-f31f-4938-9552-1712a54b21e6@z7
    > 2g2000hsb.googlegroups.com>, Tue, 12 Aug 2008 23:56:59, Jomba
    > <> posted:
    >>
    >>In folder image i have 24 pictures, and i would like to have some
    >>javascript that will every hour put another picture as background
    >>image.

    >
    > Do you mean for the image to be loaded only with the page, and remain as
    > long as the page remains displayed, or do you want a new image to be
    > fetched each hour, in the manner of a clock? To get a good answer, a
    > good question is required.
    >
    > It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
    >
    > --
    > (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk IE7 FF2 Op9
    > Sf3
    > news:comp.lang.javascript FAQ
    > <URL:http://www.jibbering.com/faq/index.html>.
    > <URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates,
    > sources.
    > <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items,
    > links.
     
    Ivan, Aug 13, 2008
    #4
  5. In comp.lang.javascript message <3eb4fa97-80ed-49fb-99c4-4e28f74061f3@34
    g2000hsh.googlegroups.com>, Wed, 13 Aug 2008 03:42:28, Bart Van der
    Donck <> posted:
    >Jomba wrote:
    >
    >> In folder image i have 24 pictures, and i would like to have some
    >> javascript that will every hour put another picture as background
    >> image.

    >
    > document.body.style.backgroundImage = 'url('
    > + (new Date()).getHours()
    > + '.jpg)';


    At a given instant, you and I will see different images. If that is not
    wanted, use getUTCHours().

    ====

    I see a bug with Firefox 2.0.0.16 : Menu Help, Check for Updates reports
    "There are no new updates available". But <http://www.mozilla-
    europe.org/en/firefox/> truthfully says to me "Firefox 3 Free Download
    Windows (3.0.1, English (British), 7MB)".

    --
    (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk BP7, Delphi 3 & 2006.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
    <URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ;
    NOT <URL:http://support.codegear.com/newsgroups/>: news:borland.* Guidelines
     
    Dr J R Stockton, Aug 14, 2008
    #5
  6. Jomba

    Paul Lautman Guest

    Dr J R Stockton wrote:
    > In comp.lang.javascript message
    > <3eb4fa97-80ed-49fb-99c4-4e28f74061f3@34 g2000hsh.googlegroups.com>,
    > Wed, 13 Aug 2008 03:42:28, Bart Van der Donck <>
    > posted:
    >>Jomba wrote:
    >>
    >>> In folder image i have 24 pictures, and i would like to have some
    >>> javascript that will every hour put another picture as background
    >>> image.

    >>
    >> document.body.style.backgroundImage = 'url('
    >> + (new Date()).getHours()
    >> + '.jpg)';

    >
    > At a given instant, you and I will see different images. If that is
    > not wanted, use getUTCHours().
    >
    > ====
    >
    > I see a bug with Firefox 2.0.0.16 : Menu Help, Check for Updates
    > reports "There are no new updates available". But
    > <http://www.mozilla- europe.org/en/firefox/> truthfully says to me
    > "Firefox 3 Free Download Windows (3.0.1, English (British), 7MB)".


    How is that a bug? Firefox 3 is not an Update to Firefox 2.
     
    Paul Lautman, Aug 14, 2008
    #6
  7. Jomba

    RobG Guest

    On Aug 13, 4:56 pm, Jomba <> wrote:
    > Hi everyone,
    >
    > In folder image i have 24 pictures, and i would like to have some
    > javascript that will every hour put another picture as background
    > image.


    Have you considered changing the image on the server? Every hour you
    could replace say 'background.jpg' with a copy of a different image,
    also called 'background.jpg'.


    --
    Rob
     
    RobG, Aug 14, 2008
    #7
  8. Jomba

    Evertjan. Guest

    RobG wrote on 14 aug 2008 in comp.lang.javascript:

    > On Aug 13, 4:56 pm, Jomba <> wrote:
    >> Hi everyone,
    >>
    >> In folder image i have 24 pictures, and i would like to have some
    >> javascript that will every hour put another picture as background
    >> image.

    >
    > Have you considered changing the image on the server? Every hour you
    > could replace say 'background.jpg' with a copy of a different image,
    > also called 'background.jpg'.


    Better use dedicated 404.asp for that:

    <%
    qstr = lcase(Request.ServerVariables("QUERY_STRING"))
    if right(qstr,15)="/background.jpg" then
    response.redirect "/myDir/myHourPic" & hours(now) & ".jpg"
    end if
    %>
    You have reached my 404 page.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Aug 14, 2008
    #8
  9. Jomba

    Evertjan. Guest

    Evertjan. wrote on 14 aug 2008 in comp.lang.javascript:

    > RobG wrote on 14 aug 2008 in comp.lang.javascript:
    >
    >> On Aug 13, 4:56 pm, Jomba <> wrote:
    >>> Hi everyone,
    >>>
    >>> In folder image i have 24 pictures, and i would like to have some
    >>> javascript that will every hour put another picture as background
    >>> image.

    >>
    >> Have you considered changing the image on the server? Every hour you
    >> could replace say 'background.jpg' with a copy of a different image,
    >> also called 'background.jpg'.

    >
    > Better use dedicated 404.asp for that:
    >
    > <%
    > qstr = lcase(Request.ServerVariables("QUERY_STRING"))
    > if right(qstr,15)="/background.jpg" then
    > response.redirect "/myDir/myHourPic" & hours(now) & ".jpg"
    > end if
    > %>
    > You have reached my 404 page.



    Or just do:

    <img src='mySwitchingJpg.asp'>

    =========== mySwitchingJpg.asp ============
    <% 'vbs
    Response.Expires = -100
    response.redirect "/myDir/myHourPic" & hours(now) & ".jpg"
    %>
    ===========================================

    sorry vbs, OT.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Aug 15, 2008
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. guest
    Replies:
    0
    Views:
    329
    guest
    Feb 4, 2007
  2. guest
    Replies:
    4
    Views:
    443
    Chris F.A. Johnson
    Feb 5, 2007
  3. Replies:
    2
    Views:
    882
    Hal Rosser
    Jun 1, 2007
  4. ssylee
    Replies:
    4
    Views:
    519
    Thad Smith
    Jan 1, 2008
  5. Chris Gunnels
    Replies:
    4
    Views:
    162
    Robert Klemme
    Sep 16, 2010
Loading...

Share This Page