By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,620 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,620 IT Pros & Developers. It's quick & easy.

every hour another background image

P: n/a
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!
Aug 13 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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
Aug 13 '08 #2

P: n/a
In comp.lang.javascript message <51dac5b5-f31f-4938-9552-1712a54b21e6@z7
2g2000hsb.googlegroups.com>, Tue, 12 Aug 2008 23:56:59, Jomba
<iv*********@gmail.composted:
>
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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Aug 13 '08 #3

P: n/a
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" <jr*@merlyn.demon.co.ukje napisao u poruci interesnoj
grupi:r+**************@invalid.uk.co.demon.merlyn. invalid...
In comp.lang.javascript message <51dac5b5-f31f-4938-9552-1712a54b21e6@z7
2g2000hsb.googlegroups.com>, Tue, 12 Aug 2008 23:56:59, Jomba
<iv*********@gmail.composted:
>>
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.htmjscr maths, dates,
sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items,
links.
Aug 13 '08 #4

P: n/a
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 <ba**@nijlen.composted:
>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.htmclpdmFAQ;
NOT <URL:http://support.codegear.com/newsgroups/>: news:borland.* Guidelines
Aug 14 '08 #5

P: n/a
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 <ba**@nijlen.com>
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.
Aug 14 '08 #6

P: n/a
On Aug 13, 4:56*pm, Jomba <ivanbaga...@gmail.comwrote:
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
Aug 14 '08 #7

P: n/a
RobG wrote on 14 aug 2008 in comp.lang.javascript:
On Aug 13, 4:56*pm, Jomba <ivanbaga...@gmail.comwrote:
>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)
Aug 14 '08 #8

P: n/a
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 <ivanbaga...@gmail.comwrote:
>>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)
Aug 15 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.