Click to See Complete Forum and Search --> : HELP!! Timezone JavaScript


his boy elroy
04-09-2003, 10:55 AM
Hello everyone:

I am working on a page (http://edesedoret.com/company.html) for my new site which contains a map, that illustrates the position of the sun based on GMT. I received JavaScript which would enable images (stored in maps bin numbered 00.gif to 23.gif) to change every hour based on the GMT.

I notice that when I initially go to the page it shows the map image that I have positioned in Dreamweaver and then switches to the correct image (when you refresh the screen it does the same). Is there a way that I can eliminate this quirk, I tried using an image place holder but that didn't work. Do you have any suggestions on how to resolve this?

I found a site with a similar feature and I copied the following code (see below). I noticed in the image line (img src=) it shows the current image rather than the one placed in the document (and the file in this line changes every hour). I couldn't find any JavaScript code associated with this, but then again I may not know what to look for:

<!-- use hour to select map image -->



<td valign="top" width="445"> <img src="/company/graphics/timezone_images/GMT_13.gif" width="471" height="253" border="0" alt="world map" usemap="#Map"></td>

Thanks

Jona
04-09-2003, 11:04 AM
<html><head>
<script>
function chngImg(){
var d = new Date();
d = d.getHours();
if(d==0){document.images['yourImg'].src="00.gif";}
else if(d==1){document.images['yourImg'].src="01.gif";}
else if(d==2){document.images['yourImg'].src="02.gif";}
//etc... keep adding else if's
else { //the image if it is a different hour. This is most likely where you will add 24.gif if there is one;
}
}
</script>
</head><body onload="chngImg();">
<!-- Image below. Notice there is no SRC. This prevents the user from seeing an image before the chngImg(); function takes effect -->
<img name="yourImg" width="70" height="70">
</body></html>

anarchist
04-09-2003, 11:07 AM
it sounds like they've done some server side scripting there

what you could do for yours is use javascript to write the image tag at runtime, so you'll need a document.write('<img src="' + imagename + '" ... etc

I'll try to clear that up as it doesnt sound to good to me

when the page is loading you need to run the javascript that gets the time and decides which image to show, then at the point where the image should be use a document.write to create the image tag, after that it should be ran as normal

his boy elroy
04-09-2003, 11:30 AM
Jona

Thanks, I don't have a 24.gif, will that be a problem?

E

khaki
04-09-2003, 01:30 PM
I don't have a 24.gif, will that be a problem?Military time (or whatever it's conventionaly called :rolleyes: ) does not have a 24th hour.

The last time before 0000.01 is 2359.59 (23rd hour).

There should be no need for a 24th image (right? :confused: )
The hour should revert to 00 (right? :confused: )

So... you should be good to go (right? :confused: )

exceptionally sure and unsure at the same time... for whatever reason...
;) k

Jona
04-09-2003, 03:53 PM
:p I forgot you said, "Army Time"! LOL! Yah, 23 images then. :D