Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1066699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:03:20+00:00 2026-05-16T20:03:20+00:00

My markup is a simple div element with id ‘load’. Using jQuery I then

  • 0

My markup is a simple div element with id ‘load’. Using jQuery I then load a list of image elements into this div:

$('#load').load('images.html', { }, function() {
  $(this).onImagesLoad({
    selectorCallback: function() {
      ....do something....
    }
  });
});

where images.html is a list like this:

<img src='1.jpg' caption='img 1'>
<img src='2.jpg' caption='img 2'>
...

To ensure that all images are loaded completely, I use the onImagesLoad plugin. This, so far, works just fine on all browsers.

However, on IE8 (and I assume other versions of IE also) when I then iterate over the img elements, I am unable to determine the width/height of the images loaded. The image.context.naturalWidth and naturalHeight attributes don’t seem to work.

How do I get a hold of the images’ dimension?

Thanks heaps 🙂

Update

@Simon: That didn’t work on IE, and broke the other browsers as well.

@Jenechka: If “imageDomElement” is just another name for the “image” variable in my example above, then it doesn’t work. Or what do you mean by that DomElement?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:03:20+00:00Added an answer on May 16, 2026 at 8:03 pm

    It’s been a while but I finally found some time to tinker with this again. The above problems are still there, but here is what I think is going on.

    When I load the initial images then yes, the file is loaded and image objects are generated. But it seems that the attributes are not correct yet, and they won’t be until the image is actually added to the DOM of the site and rendered. A div/image on hide() on IE has no dimension information whatsoever, on Safari there is some information available. For example, without adding the following div anywhere

    var test = $("<div><img src='test.jpg'></div>")
    

    the image contained there has the following information:

    • width() = 0,
    • attr("width") = 600,
    • css("width") = "", and
    • img[0].clientWidth = 0.

    That’s on Safari; on IE it’s the same except attr("width") = 0 and css("width") = "auto". Now I can’t use this, and that’s what broke my script and why I posted my initial question. However, the moment I append this div and have it rendered, all the correct values show up in the image object.

    I’m writing a little gallery thinghie, which shows whatever images I have in that second .html file that I load; that gallery, however, computes and places the thumbnails, and prepares the images it shows in full resolution. To make this look ok, I basically wanted to create the entire thing hidden, and then fade it in. Alas, it seems that this whole idea won’t pan out. A friend suggested to load everything into a tiny iframe off to the left where it’s not visible, and work with that. Perhaps that’s the way to go.

    Another thing I noticed, and that seems to be very closely related to the aforementioned load issue is clone(). It seems that if an image is rendered, a

    var newimg = img.clone()
    

    generates the same “empty” image object that I have to deal above. Even when the original image is visible and contains all the right attributes, its clone does not.

    Right now I don’t see any other way than to rethink and rewrite parts of my gallery.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this simple markup: <body> <div style=border: 2px solid navy; position:absolute; width:100%; height:100%> </div>
Okay, so I'm designing this site. Here's the HTML markup of this simple element:
Ive been writing a simple jquery function that turns a div with a list
Here's a simple example to illustrate the behavior: Given this html markup: <div data-company=Microsoft></div>
I've got this simple markup: <div id=parent> <div id=static> Hello Random </div> <div id=max>
I'm trying to create a simple markup with templates. Something like: <div class=list data-bind=template:
I have some simple markup: <table> <tr> <td>Menu Item</td> </tr> </table> <div> <table> <tr>
Simple question: I have the following markup... <a href='#'> <img src='icon.png'> This is the
i have a simple markup with a navigation div , a content div and
I'm having troubles with a simple menu hide/show with jQuery. The HTML markup is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.