images not showing even after pre load

C

Charlie

Hi
I am using the following code to create an image viewer for multiple
images.

var pageImage = document.images['mainImage'];
var image = new Image();
var args = GetQuerystring(); //return arguments from querystring
image.src = args.imageSource; //get image src
pageImage.src = "";
pageImage.src = image.src;


IE one image after another using one page as the viewer. The view
loads the image into an Image object and then displays it on the page
after doing some resizing etc

However I am getting erroneous results from time to time. Most of the
images will load in the viewer, then I will get one that doesn't load,
it doesn't even show a placeholder, it will load if refresh is hit or
if the viewer is moved on to another image and then moved back.

I have also tried setting the src of the image to "" and then setting
the src to the new image with no luck. I could of course load all the
images into the cache, but with potentially hundreds of images, this
is impractical.

Any help would be very gratefully received

Cheers

Charlie
 
F

Frank

First of all I would never use 'image' as variable name, rather
'anImage' although it seems that it is not a reserved word.
I have had luck with using the setTimeout method when changing image
source. Try this:
var anImage = new Image();
......
setTimeout(anImage.src = args.imageSource;',5);
......

If that does not work, make sure your GetQueryString method works ok,
put an alert after it, so:
......
var args = GetQuerystring();
alert(args);
......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top