HighDots Forums  

images not showing even after pre load

Javascript JavaScript language (comp.lang.javascript)


Discuss images not showing even after pre load in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Charlie
 
Posts: n/a

Default images not showing even after pre load - 10-05-2003 , 06:50 PM






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

Reply With Quote
  #2  
Old   
Frank
 
Posts: n/a

Default Re: images not showing even after pre load - 10-21-2003 , 03:55 PM






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);
......

subs (AT) acheson-crow (DOT) com (Charlie) wrote in message news:<57065011.0310051450.13bf34c5 (AT) posting (DOT) google.com>...
Quote:
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.