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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:06:19+00:00 2026-06-13T06:06:19+00:00

I am trying to run some code that grabs the width and height of

  • 0

I am trying to run some code that grabs the width and height of a div after it is loaded and filled with an image from an AJAX call.

The div is 0x0 until the image is placed so checking the dimensions before pretty much breaks everything.

I have tried .load() (Doesn’t work because this is an AJAX call). I also tried the imagesLoaded js plugin. Here is what I have right now:

alert('outside;')
function startBubbles(){
    alert('inside');
    var space = new DisplaySpace($('#bubbleWrap').height(), $('#bubbleWrap').width());
    var count = 1;
    alert(space.getHeight());
    var delay = (function(){
      var timer = 0;
      return function(afterResize, ms){
        clearTimeout (timer);
        timer = setTimeout(afterResize, ms);
      };
    })();

    var spawnInterval = self.setInterval(function(){
        var aBubble = new Bubble(count, space);
        count++
        aBubble.spawnimate(aBubble);
        setTimeout(function() {aBubble.popBubble(aBubble)},Math.floor((Math.random()*30000)+10000));
    }, 500);
});

My alerts all fire before the image is visible, then my ‘space’ object still has height and width of 0.

bubbleWrap is a div inside the loading zone that contains the image in question. I realize I could probably but a manual delay in here to solve the problem MOST of the time – however that doesn’t seem optimal. What am I missing?

I’m now implementing the load of this particular state like this:

History.Adapter.bind(window,'popstate',function(){ 
                var state = History.getState(); 
                state = 'target='+state.data.state;
                $.get('contents.php', state, function(data){
                    if(state == 'target=bubbles'){
                        $('#loading_zone').html(data).waitForImages(startBubbles());
                    }
                    else{
                        $('#loading_zone').html(data);
                    }

                });
        });

Unfortunately, on page reload, the height ends up as only 10. Everything seems great when I just navigate away and come back, though. Any thoughts?

  • 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-06-13T06:06:21+00:00Added an answer on June 13, 2026 at 6:06 am

    I have a plugin that could do this nicely.

    Simply call it after you inject the new HTML.

    // Assume this function is the callback to the *success*.
    function(html) {
        $("#target").html(html).waitForImages(function() {
            // All descendent images have now loaded, and the 
            // containing div will have the correct dimensions.
        });
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run some javascript code that is created by my codebehind
What I'm trying to do is run some JavaScript code that will enter text
I'm trying to run some tests on some Ajax code we have written, now
I'm trying to always run some code after .find or .where or whatever is
So I was trying to run some simple code with Code Contracts (that I
I am trying to run some code from a book . There appears to
in my app I am trying to run some code that currently exists in
I'm trying to run some external executable code from within Python and then make
I am trying to write some code that uses SQL to delete rows from
I am trying to run some code that will start a particular animation when

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.