script.js 870 B

1234567891011121314151617181920
  1. // https://www.dyn-web.com/tutorials/iframes/height/
  2. function getDocHeight(doc) {
  3. doc = doc || document;
  4. // stackoverflow.com/questions/1145850/
  5. var body = doc.body, html = doc.documentElement;
  6. var height = Math.max(body.scrollHeight, body.offsetHeight,
  7. html.clientHeight, html.scrollHeight, html.offsetHeight);
  8. return height;
  9. }
  10. function setIframeHeight(id) {
  11. var ifrm = document.getElementById(id);
  12. var doc = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document;
  13. requestAnimationFrame(function() { // http://wilsonpage.co.uk/preventing-layout-thrashing/
  14. // ifrm.style.visibility = 'hidden';
  15. ifrm.style.height = "10px"; // reset to minimal height ...
  16. // IE opt. for bing/msn needs a bit added or scrollbar appears
  17. ifrm.style.height = getDocHeight(doc) + 4 + "px";
  18. // ifrm.style.visibility = 'visible';
  19. });
  20. }