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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:10:10+00:00 2026-05-18T00:10:10+00:00

I have a JavaScript code that adds new XHTML to already existing page (DOM

  • 0

I have a JavaScript code that adds new XHTML to already existing page (DOM tree).
My page elements are dynamic, so adding new elements causes changes in other elements size. I have a custom scroll bar implementation that depends on those sizes and needs to be reset every time they change.

I call the reset method shortly after the statement that inserts the new XHTML. But it seems that this is too soon. Sometimes the scrollbar does not adjust properly. If I add some delay before reset, it is OK, but I consider it too crude and unreliable solution.

I need to either:

Detect when given DOM element completes change of size

or

Detect when the entire DOM change finishes along with the re-layout.

So far I could not find nothing. I know the situation is too complex for most people, but I hope somebody will be able to help. Thanks!

  • 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-18T00:10:10+00:00Added an answer on May 18, 2026 at 12:10 am

    How about some polling where you check the state of the dom? This is with jQuery and will call resetMyScrollbar whenever the html in the page body updates with a maximum half second delay.

    var lastDom = "";
    function checkDomHash() {
      var newDom = $("body").html();
      if (newDom != lastDom) {
        resetMyScrollbar();
      }
      window.setTimeout(checkDomHash, 500);
    }
    

    In real life I’d use a hash function and compare hashes as comparing huge strings is wasteful.

    var lastDomHash = "";
    ...
      var newDomHash = md5OrWhatever($("body").html());
      ...
    

    Edit

    Or you could check the height of whatever the scroll bar is for.

    var lastHeight = 0;
    ...
      var newHeight = $("#my_element_id").outerHeight();
      ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some JavaScript code that resizes <div/> elements (adjusts height/width/padding/margin etc.) based on
I have written some JavaScript code. It adds new function to NodeList type in
I have a Javascript plugin that searches the DOM for any elements starting with
I have some jQuery/JavaScript code that I want to run only when there is
I have this function in my Javascript Code that updates html fields with their
I have some code in a javascript file that needs to send queries back
I'm writing a web page in ASP.NET. I have some JavaScript code, and I
I have some javascript code that is used in a few different pages in
I have a project that adds elements to an AutoCad drawing. I noticed that
I have seen Javascript code that claims to speed up function call overhead like:

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.