Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > every hour another background image

Reply
Thread Tools

every hour another background image

 
 
Jomba
Guest
Posts: n/a
 
      08-13-2008
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!
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      08-13-2008
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
 
Reply With Quote
 
 
 
 
Dr J R Stockton
Guest
Posts: n/a
 
      08-13-2008
In comp.lang.javascript message <51dac5b5-f31f-4938-9552-1712a54b21e6@z7
2g2000hsb.googlegroups.com>, Tue, 12 Aug 2008 23:56:59, Jomba
<(E-Mail Removed)> 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.
 
Reply With Quote
 
Ivan
Guest
Posts: n/a
 
      08-13-2008
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" <(E-Mail Removed)> je napisao u poruci interesnoj
grupi:(E-Mail Removed). invalid...
> In comp.lang.javascript message <51dac5b5-f31f-4938-9552-1712a54b21e6@z7
> 2g2000hsb.googlegroups.com>, Tue, 12 Aug 2008 23:56:59, Jomba
> <(E-Mail Removed)> 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.


 
Reply With Quote
 
Dr J R Stockton
Guest
Posts: n/a
 
      08-14-2008
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 <(E-Mail Removed)> 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
 
Reply With Quote
 
Paul Lautman
Guest
Posts: n/a
 
      08-14-2008
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 <(E-Mail Removed)>
> 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.


 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      08-14-2008
On Aug 13, 4:56*pm, Jomba <(E-Mail Removed)> 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
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-14-2008
RobG wrote on 14 aug 2008 in comp.lang.javascript:

> On Aug 13, 4:56*pm, Jomba <(E-Mail Removed)> 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)
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      08-15-2008
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 <(E-Mail Removed)> 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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to : another body background image every day? guest HTML 4 02-05-2007 05:56 PM
how to : another body background image every day? guest Javascript 0 02-04-2007 10:59 PM
how to : another body background image every day? guest HTML 0 02-04-2007 10:58 PM
Re: 24 hour <--> 12 hour vcr clock fred@nospam.com Computer Support 0 08-14-2004 07:26 AM
24 hour <--> 12 hour vcr clock fred@nospam.com Computer Support 4 08-13-2004 01:52 PM



Advertisments