...

View Full Version : text while loading image problems



thyscorpion
10-15-2006, 10:43 PM
howdy!

well its been a while since i used Javascript. i guess my problem will be a simple one for u guys/gals.

I have one Div and in that div i have kept a img tag. i change the src property of the tag depending on where the user clicks.
now i noticed on slower connections the image doesnt update itself as fast..
therefore i need a "loading please wait" sign while the new src image is loading.
how do i go about doing that?

cause while the new image is loaded the old image is still displayed! and that i dont want!..

please help!

_Aerospace_Eng_
10-15-2006, 10:46 PM
Some browsers support image onload

var img1 = new Image();
img1.src = 'test.jpg';
img1.onload = function()
{
alert('img1 has loaded');
}
What you could do is in your function that changes the picture, have a some text shown by changing a div display from none to block. Then onload of the new image change its display from block to none.

thyscorpion
10-16-2006, 07:35 AM
Some browsers support image onload

var img1 = new Image();
img1.src = 'test.jpg';
img1.onload = function()
{
alert('img1 has loaded');
}
What you could do is in your function that changes the picture, have a some text shown by changing a div display from none to block. Then onload of the new image change its display from block to none.

hey thanks man! used the onload property but with a different way! :).. thanks a ton! cheers!.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum