Still more iframe resize tweaks
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 21 Jan 2011 17:54:18 +0000 (10:54 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 21 Jan 2011 18:40:57 +0000 (11:40 -0700)
imp/js/imp.js

index c2ece1c..f66e27b 100644 (file)
@@ -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 ||