For instance I would like to place a picture
M-F at 6-10am morning.png
M-F at 2-6pm evening.png
then on Sunday 6-11 morningmusic.png
I have tried the following code but the picture show at the wrong time. Can anyone help.
In the <head> I have
<script type="text/javascript" src="timePictureChange.js"></script>
In the body I have
<img src="" id="myimage" alt="time of day">
And as the javascript I have:
function pixTimeChange() {
var t=new Date();
var h = t.getUTCHours();
var d = t.getUTCDay();
var weekday=new Array(7);
weekend[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
var r1="images/onairimages/musicalsoulfoodairimage.png";
var r2="images/onairimages/sherriairimage.png";
var r3="images/onairimages/calairimage.png";
var r4="images/onairimages/nateairimage.png";
var el=document.getElementById('myimage');
// See the time below. Note: The time is in 24 hour format.
// In the example here, "7" = 7 AM; "17" =5PM.
el.src = (h>=11 && h<15) ? r1 : r2;
el.src = (h>=19 && h<23) ? r1 : r3;
}
// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
addLoadEvent(function() {
pixTimeChange();
});
Can anyone Help Please!!!

New Topic/Question
Reply


MultiQuote







|