Jump to content

Image Loading


javascriptman19

Recommended Posts

If I do

 

 

<img id="IMAGE2" src="" style="max-width: 200px; max-height: 300px;">document.getElementById("IMAGE2").src = 'test.jpg';imgheight = document.getElementById("IMAGE2").offsetHeight;

 

 

on img's with max-width / max-height attributes not ones with fixed height/width....

 

sometimes i get 0 and sometimes i get a number...

 

then i noticed if i set the image... then set a timeout for 300 miliseconds then the offsetHeight always gives a number... can someone explain this to me? is the code going on before the image gets resized by the browser causing there to be no height to return resulting with the 0?

Link to comment
Share on other sites

I GOT IT!!!

 

with max/min height/widths... theres no pre-set height/width so u don't know it until the image fully downed/rendered... thats the problem...

 

i got a question though... as the image downloads does it render at the same time... or does it download in the background then render? and if so can u get the height/width settings if it downloaded but has rendered yet? even though its like a 1 second process

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.