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 6634217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:54:14+00:00 2026-05-25T22:54:14+00:00

Works in all browsers except <= IE7.. Check this example, http://jsfiddle.net/uVRbG/1 in iE7. When

  • 0

Works in all browsers except <= IE7..

Check this example, http://jsfiddle.net/uVRbG/1 in iE7.

When I remove the style display:none from the object however, it works correctly:

http://jsfiddle.net/uVRbG/2/

I don’t get it, I simply want the hardcoded value…it shouldn’t matter whether or not the object is visible at the time.. Is there any other method to get the width and height?

Note: I need the width and height at document.ready, I can’t wait for all these images to load and then use img.width();

HTML:

<div id="test" style="display:none">
<img src="http://neuro.amygdala.net/wp-content/uploads/2007/11/i-stress-test.gif" width="100" height="100" />
</div>

<div id="result"></div>
<div id="result2"></div>

Javascript:

$('#result').html($('#test img:first').attr('width'));
$('#result2').html($('#test img:first')[0].getAttribute('width'));

Thanks,
Wesley

  • 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-25T22:54:14+00:00Added an answer on May 25, 2026 at 10:54 pm
    .width()
    

    might help you, but as to why IE7 has a problem with this, I think it might be to do with your selector.

    I’ve always had trouble with :first and :last pseudo-selectors in IE, it might just not be selecting the image.
    .attr() doesn’t have any bugs with display:none afaik.

    Hope this helps

    EDIT:
    Try adding this to your fiddle:

    var imgWidth = $($('#test').html()).attr('width');
    alert(imgWidth);
    

    Bit of a hacky workaround but might work. I’ve tried and can’t test with IE7, it throws a script error when I load jsfiddle >:(

    EDIT:
    Last resort, a regex:

    var imgWidth = $('#test').html().search(/width=[\"\'][0-9]+/);
    alert(imgWidth);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://jsfiddle.net/zerkms/4zJyw/1/ In all major browsers, except of IE7, the example works as expected -
This works in all browsers except IE7 and IE8 ( and probably IE6 ).
This code below works in all web browsers except IE: <input type="text" name="passwordLogin" value="Password"
web page : http://sideradesign.com/eco-art/gallery/ This code works fine in all brwosers except IE8 (haven't
My site works with all the browsers ive tested with except for IE7 (im
UPDATE: I have updated my HTML. Now it works in all browsers except IE7.
I made a navbar and it works perfectly in all browsers except IE7. Below
The following Google map (api v.3) works fine in all browsers except IE7, seems
This code below works perfectly for all browsers except IE 7 or 8. <img
This works in all browsers except IE. I have no idea why. Its just

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.