From b335fbfff408f8cc0fc31bd185d3a74d7356b74d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 21 Jan 2011 10:54:18 -0700 Subject: [PATCH] Still more iframe resize tweaks --- imp/js/imp.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/imp/js/imp.js b/imp/js/imp.js index c2ece1c10..f66e27bed 100644 --- a/imp/js/imp.js +++ b/imp/js/imp.js @@ -80,7 +80,7 @@ document.observe('dom:loaded', function() { id = $(id); var d = id.contentWindow.document; - id.observe('load', IMP.iframeResize.bind(IMP, id)); + id.observe('load', function() { IMP.iframeResize.bind(IMP, id).defer(0.3); } ); d.open(); d.write(data); @@ -91,18 +91,16 @@ document.observe('dom:loaded', function() { IMP.iframeResize = function(id) { - if (id = $(id)) { - id.stopObserving('load').setStyle({ height: id.contentWindow.document.lastChild.scrollHeight + 'px' }); - - // For whatever reason, browsers will report different heights - // after the initial height setting. - this.iframeResize2.bind(this, id).defer(0.3); + if (!(id = $(id))) { + return; } - }; - IMP.iframeResize2 = function(id) - { + id.stopObserving('load'); + var lc = id.contentWindow.document.lastChild; + if (!lc.scrollHeight) { + lc = id.contentWindow.document.body; + } // Try expanding IFRAME if we detect a scroll. if (lc.clientHeight != lc.scrollHeight || -- 2.11.0