Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

time based image alteration - Help

Status
Not open for further replies.

Blui

Technical User
Mar 26, 2006
3
GB
Hi People, I have spent seveearl hours trying to find a javascript code that will do the following:-
If the clients computer time is between 7am and 8pm it shows a particular image and if the computers time is between 8pm and 7am it dipslays a different image, The header will alter basically to suit night time or day time.
Can someone please point me in the right direction (I've been looking all day)?
Is it possible for this to be achieved by CSS?
Thanks for any light you can shed on this, Cheers Blu
 
...I've been looking all day...
So, what have you found? What direction did your programming take you? What problem are you having? Remember, this is a place where we help you solve problems with your code (not write the code for you).

Regarding your question as to whether it can be solved using pure CSS... no... it can't.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Have a look at this post from a week or so ago, "Redirect depending on what time of day it is" (thread216-1206297).

It shows how to do things at different times of the day.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks people, I eventually managed to get it working - the codes below should anyone need it:-

<script type="text/javascript">
var current= new Date()
var day_night=current.getHours()
if (day_night<=20 || day_night > 7)
document.write("<img src='boatblueheader.jpg'>")
else
document.write("<img src='boatniteheader2.jpg'>")
</script>
 
Sorry, I got it wrong it doesn't work correctly, the time if statement is not working correctly:-

if (day_night<=20 || day_night > 7)

It needs to be 7am till 8pm (0700 to 2000),
again any help would be appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top