IMG src attribute loads too slow!

  • Thread starter Thread starter John Bailo
  • Start date Start date
J

John Bailo

I have a table with 2 columns, and one row.

The first column cell has navigation links.

The second column has an empty IMG tag.

When I click on a link in the first column, it runs a javascript
function that sets the value of the IMG.src to an image file.


_Problem_

In IE6, the image loads so slowly into the IMG.src tag, that it doesn't
display.


_Tests_

1) The page will work just fine in Firefox, Safari and Konqueror (Linux).

2) I added an alert to just after the .src is set, and it loads just
fine (because I give it time to load).

3) I added a wait function that pauses it -- if i set that to 1000
milleseconds (1s) then the image has time to load.

4) If I reduce the image from 100K to a very small image, it loads just
fine.


_Question_

Is there any way to test when the image has fully loaded and then have
the javascript function proceed?
 
Hi John,
I don't know of any client side scripting that detects when an image has
completed downloading. Macro Media uses a preload images function to
download all images with the initial page rendering, this may be of help but
I suspect that it will make your page loading intollerably slow if you are
using large sized images. An alternative stategy may be to alter the format
of your large images that reduces the download file size (jpg?).

I am not sure but because you are setting the scr value on the fly, the
browser may be re-rendering the whole page. An alternative may be to load
the larger image into its own pop-up window (window.open etc)
I trust that I have been of help.
 
Rob said:
Hi John,
I don't know of any client side scripting that detects when an image has
completed downloading. Macro Media uses a preload images function to
download all images with the initial page rendering, this may be of help but
I suspect that it will make your page loading intollerably slow if you are
using large sized images. An alternative stategy may be to alter the format
of your large images that reduces the download file size (jpg?).

Thanks Rob. This page was actually developed with MacroMedia which
scripted all the javascript and includes a preload function. Yet, the
problem still exists (only in IE) with an image that is 100K in size
(not that big in my book).
I am not sure but because you are setting the scr value on the fly, the

I set it in response to an onClick on a hyperlink on the left hand side.
browser may be re-rendering the whole page. An alternative may be to load
the larger image into its own pop-up window (window.open etc)

Actually, it doesn't seem to be doing a postback (I don't think onClick
does that), but what seems to be happening, is that in the javascript
function, it sets the scr and then returns back to the page. If it
takes too long, it either doesn't load, or, in some cases, it loads some
of the image (like the top 15%).

Other than guessing and putting in a wait step of 2s, I don't see how I
can confirm that IE has finished loading the image before proceeding to
returning from the javascript function.
 
Back
Top