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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Background By Time Of Day? 1

Status
Not open for further replies.

peitzza

Technical User
Apr 13, 2000
80
US
Does anyone know a script I could use to change my page background dynamicaly by the time of day? e.g. 6:00am has one backround image, 12:00pm has another image, 8:00pm another, and so on.

Thanks in advance,
-Peter

Peter Heaton
heaton@characterlink.net
 
Oops, I finaly found what I was looking for like 5 minutes after posting the above message. Anyway for anyone else who is curious, here's the script:

<script language=&quot;JavaScript&quot;>

day=new Date() //..get the date

x=day.getHours() //..get the hour

if(x>=0 && x<4) {

document.write('<body background=&quot;put your first image file name here such as 1.jpg&quot;>')

} else

if(x>=4 && x<12) {

document.write('<body background=&quot;put your second image file name here such as 2.jpg&quot;>')

} else

if(x>=12 && x<18) {

document.write('<body background=&quot;put your third image file name here such as 3.jpg&quot;>')

} else

if (x>=18 && x<24) {

document.write('<body background=&quot;put your last image file name here such as 4.jpg&quot;>')

}

</script>

I might also add that I found this at:

-Peter

Peter Heaton
heaton@characterlink.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top