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