Preloading Images into Javascript variables

G

Guest

Can anyone help me with this problem:

I am trying to preload images, but I am not doing them the traditional way
(which works fine):

<script language=javascript>
var myImage = new Image()
myImage.src = 'mylocalfile.gif'
</script>

..... in the html body

<img src = myImage.src </img>

Instead, I need to use the results of an aspx page (which writes out an
image to the response stream):

<script language=javascript>
var myImage = new Image()
myImage.src = 'http://localhost/makemeanimage.aspx?size=120'
</script>

..... in the html body

<img src = myImage.src </img>

This doesn't throw an error, but the image is always missing. It always
works if I use a local image file, but not an image served from the aspx page.

Strangely enough, the following DOES work though:

<img src = 'http://localhost/makemeanimage.aspx?size=120' </img>

I could just do this, but I need to use the images in a rollover, which
would be very slow on modem speed connections if the page is hit every time
the rollover occurs.

Does this mean that I can't preload images served from an aspx page in
javascript?

using vs 2003 windows xp ie6

thanks

sorry about the double post
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top