Click to See Complete Forum and Search --> : Time of day image changer


ajhenderson
02-18-2004, 03:29 PM
I'm trying to have an image that changes based on time of day. The code I'm using now, which is not working, is below. Maybe I need a whole new approach.

What I really need is for this code to be in effect Monday-Friday, and have different image (only one) appear on Saturday and Sunday.

Thanks for your help.

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
document.write("<a href="javascript:SurferHandler()>")
day = new Date()
hr = day.getHours()
if ((hr == 22) || (hr == 23) || (hr == 0))
document.write("<img src="/kfnx/images/onair/vortex.gif" border=0>")
if ((hr == 1) || (hr == 2) || (hr == 3) || (hr == 4) || (hr == 5))
document.write("<img src="/kfnx/images/onair/hottalk.gif" border=0>")
if ((hr == 6) || (hr == 7) || (hr == 8))
document.write("<img src="/kfnx/images/onair/morning.gif" border=0>")
if ((hr == 9) || (hr == 10))
document.write("<img src="/kfnx/images/onair/drsam.gif" border=0>")
if ((hr == 11) || (hr == 12))
document.write("<img src="/kfnx/images/onair/mohan.gif" border=0>")
if ((hr == 13) || (hr == 14))
document.write("<img src="/kfnx/images/onair/sydney.gif" border=0>")
if ((hr == 15) || (hr == 16) || (hr == 17))
document.write("<img src="/kfnx/images/onair/newcomb.gif" border=0>")
if ((hr == 18) || (hr == 19))
document.write("<img src="/kfnx/images/onair/han****.gif" border=0>")
if ((hr == 20) || (hr == 21))
document.write("<img src="/kfnx/images/onair/bolling.gif" border=0>")
document.write("</a>")
// End -->
</SCRIPT>

ajhenderson
02-18-2004, 03:38 PM
I used a different code and things work fine now... EXCEPT I still need a way to differentiate between days of the week. I want the hottalk.gif button to run from 1am Saturday to 12am Monday. Ideas?

<a href="javascript:SurferHandler()">
<script>

//Time of day message script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use

var Digital=new Date()
var hours=Digital.getHours()

//Configure message below to your own.
if (hours>=6&&hours<=9) //MESSAGE FOR MORNING
document.write('<img src="/kfnx/images/onair/morning.gif" border=0>')
else if (hours>=9&&hours<=11) //MESSAGE FOR AFTERNOON
document.write('<img src="/kfnx/images/onair/drsam.gif" border=0>')
else if (hours>=11&&hours<=13) //MESSAGE FOR EVENING
document.write('<img src="/kfnx/images/onair/mohan.gif" border=0>')
else if (hours>=13&&hours<=15) //MESSAGE FOR NIGHT
document.write('<img src="/kfnx/images/onair/sydney.gif" border=0>')
else if (hours>=15&&hours<=18) //MESSAGE FOR NIGHT
document.write('<img src="/kfnx/images/onair/newcomb.gif" border=0>')
else if (hours>=18&&hours<=20) //MESSAGE FOR NIGHT
document.write('<img src="/kfnx/images/onair/han****.gif" border=0>')
else if (hours>=20&&hours<=22) //MESSAGE FOR NIGHT
document.write('<img src="/kfnx/images/onair/bolling.gif" border=0>')
else if (hours>=22&&hours<=1) //MESSAGE FOR NIGHT
document.write('<img src="/kfnx/images/onair/vortex.gif" border=0>')
else if (hours>=1&&hours<=5) //MESSAGE FOR NIGHT
document.write('<img src="/kfnx/images/onair/hottalk.gif" border=0>')

</script></a>