id might not exist at the time iframeResize() is re-run
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 28 Jan 2010 21:00:12 +0000 (14:00 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 28 Jan 2010 21:00:12 +0000 (14:00 -0700)
imp/js/imp.js

index cf01aec..7ab3b41 100644 (file)
@@ -99,14 +99,15 @@ document.observe('dom:loaded', function() {
 
     IMP.iframeResize = function(id, delay)
     {
-        id = $(id);
-        id.setStyle({ height: Math.max(id.contentWindow.document.body.scrollHeight, id.contentWindow.document.lastChild.scrollHeight) + 'px' });
-        if (!delay) {
-            // For whatever reason, browsers will report different heights
-            // after the initial height setting. Delaying a second height
-            // setting seems to work most of the time to fix this.
-            this.iframeResize.bind(this, id, true).delay(0.5);
-        }
+        if (id = $(id)) {
+            id.setStyle({ height: Math.max(id.contentWindow.document.body.scrollHeight, id.contentWindow.document.lastChild.scrollHeight) + 'px' });
+            if (!delay) {
+                // For whatever reason, browsers will report different heights
+                // after the initial height setting. Delaying a second height
+                // setting seems to work most of the time to fix this.
+                this.iframeResize.bind(this, id, true).delay(0.5);
+            }
+         }
     };
 
     // If menu is present, attach event handlers to folder switcher.