Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. window.addEventListener("load", function(){
  2. if(window.self === window.top) return; // if w.self === w.top, we are not in an iframe
  3. function send_height_to_parent_function(){
  4. var height = document.getElementsByTagName("html")[0].clientHeight;
  5. //console.log("Sending height as " + height + "px");
  6. parent.postMessage({"height" : height }, "*");
  7. }
  8. // send message to parent about height updates
  9. send_height_to_parent_function(); //whenever the page is loaded
  10. window.addEventListener("resize", send_height_to_parent_function); // whenever the page is resized
  11. var observer = new MutationObserver(send_height_to_parent_function); // whenever DOM changes PT1
  12. var config = { attributes: true, childList: true, characterData: true, subtree:true}; // PT2
  13. observer.observe(window.document, config); // PT3
  14. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement