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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:33:45+00:00 2026-05-30T20:33:45+00:00

On a complex AJAX site I need to retrieve CSS-dimensions of newly inserted DOM

  • 0

On a complex AJAX site I need to retrieve CSS-dimensions of newly inserted DOM objects, i.e. the value of a certain DIVs innerWidth, so I can resize loaded images to their parents dimensions.

I am loading the new Stuff into the DOM via jQuery.load()-POST:

$( 'DIV#newStuff' ).load( 'insertthis.ajax', {id:1}, function() {
    var iMaxWidth = $( 'DIV#widthNeeded' ).innerWidth();
    console.log(iMaxWidth);
} );

The problem: FireFox (PaleMoon) 9.2 => returning “442” as expected.
Maxthon 3 and Chrome 17 => returning either “0” or a much higher value “736”.
Both on Win7. jQuery 1.7.1

I also tried the jQuery.actual()-plugin with the same results.

To clearify: this is a very much simplified extract of the actual function. I’m only trying to show the core problem. The loaded script is plain PHP (I changed the extension to .ajax).

The solution (workaround):
Wrapping the success callback code with an additional setTimeout()-function gives some browsers the dire needed time to calculate the newly rendered DOM-stuff’s dimensions proberly.

$( 'DIV#newStuff' ).load( 'insertthis.ajax', {id:1}, function() {
    setTimeout( function() {
        var iMaxWidth = $( 'DIV#widthNeeded' ).innerWidth();
        console.log(iMaxWidth);
    }, 500 );
} );
  • 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-30T20:33:46+00:00Added an answer on May 30, 2026 at 8:33 pm

    Answering your revised question:

    I can’t immediately see why you’d be getting those kinds of discrepancies. It may be that you need to give the browser a moment to reflow or something, by effectively doing a yield, like this:

    $( 'DIV#newStuff' ).load( 'insertthis.ajax', {id:1}, function() {
        setTimeout(function() {
            var iWidth = $( 'DIV#widthNeeded' ).innerWidth();
            var jqWidthKeeper = $( 'DIV#widthKeeper' );
            var iMaxWidth = jqWidthKeeper.actual( 'innerWidth' );
            console.log(iMaxWidth);
        }, 0);
    } );
    

    jQuery calls the load callback immediately after updating the element. I’ve sometimes seen browsers need you to give their rendering thread a moment to reflow.

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

Sidebar

Related Questions

I am writing a complex AJAX application at the moment and the entire site
I've implemented more complex AJAX before with javascript and PHP, but for some reason
Possible Duplicate: Complex CSS selector for parent of active child I have the following
Opening a site economizing the data load I seem to run into a need
I need to port the functionality of this one and only one AJAX control
I've got some complex AJAX going in a project that is fetching inner page
I've been successfully WebForms for AJAX calls with relatively complex set of parameters (called
I'm coding a fairly large and complex site by myself, so do you think
I am building a complex AJAX based solution as a module into a Drupal
Is there a Firefox plugin or system for testing complex ajax web applications. It

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.