JavaScript window.body.scrollHeight does not change when decreasing height window.body.scrollheight,window.document.body.scrollheight,window.scrollto(document.

So I am trying to create a way to detect when the body resizes and then I grab the new height and send it through a postmessage. The not correctly functioning part is when I downsize the body ( when I removed(hide) some elements so the body shrunk). This does not get detected as the window.body.scrollHeight simply holds the last value. Here is my code and I would appreciate any suggestions:

  sendMessage();
  checkDocumentHeight(sendMessage);
  function sendMessage(){
    var heightWidth = document.body.scrollHeight+ " " +document.body.scrollWidth;
    parent.postMessage(heightWidth, "*");
  }
  function checkDocumentHeight(callback){
      var lastHeight = document.body.scrollHeight, newHeight, timer;
      (function run(){
          newHeight = document.body.scrollHeight;
          if( lastHeight != newHeight )
              callback();
          lastHeight = newHeight;
          timer = setTimeout(run, 1000);
      })();
  }
Answer:1

I made a Character class shared by the client and server in the same js file. The server instanciates these characters and stocks them in a characterList object. I send it to the client with socket....

I made a Character class shared by the client and server in the same js file. The server instanciates these characters and stocks them in a characterList object. I send it to the client with socket....

I have two divs <div class="tab-pane active" id="home"> <div class="tab-pane" id="profile"> Each of this div has forms in it which has a hidden field <input type="hidden" name="...

I have two divs <div class="tab-pane active" id="home"> <div class="tab-pane" id="profile"> Each of this div has forms in it which has a hidden field <input type="hidden" name="...

  1. javascript class value change
  2. javascript classlist value
  3. javascript classname value
  4. javascript class value get
  5. javascript class value set
  6. javascript value to classic asp
  7. javascript value as class name
  8. javascript read class value
  9. javascript get class value of element
  10. javascript check class value
  11. javascript add class value
  12. javascript update class value
  13. javascript input class value
  14. javascript span class value
  15. javascript remove class value
  16. javascript if class value
  17. javascript html class value
  18. javascript div class value
  19. javascript td class value
  20. javascript pass class value

Currently I am using React on Rails application (using react-rails library) and I wish to use some third party React components. How to use third party component without adding dependency to ...

Currently I am using React on Rails application (using react-rails library) and I wish to use some third party React components. How to use third party component without adding dependency to ...

  1. react js without npm
  2. install react without npm
  3. use react without npm
  4. create react app without npm
  5. run react app without npm start

Update: A Solution below! I'm fairly new to website development but I've been tasked with developing e2e (end-to-end) tests for a developing website that uses AngularJS. As a result I've been looking ...

Update: A Solution below! I'm fairly new to website development but I've been tasked with developing e2e (end-to-end) tests for a developing website that uses AngularJS. As a result I've been looking ...