Resize IFRAME correctly if images are loading at injection time
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 7 Jan 2011 19:07:49 +0000 (12:07 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 7 Jan 2011 19:37:20 +0000 (12:37 -0700)
imp/js/imp.js

index bad791d..9474ac6 100644 (file)
@@ -80,18 +80,19 @@ document.observe('dom:loaded', function() {
         id = $(id);
         var d = id.contentWindow.document;
 
+        id.observe('load', IMP.iframeResize.bind(IMP, id));
+
         d.open();
         d.write(data);
         d.close();
 
         id.show().previous().remove();
-        this.iframeResize(id);
     };
 
     IMP.iframeResize = function(id)
     {
         if (id = $(id)) {
-            id.setStyle({ height: id.contentWindow.document.lastChild.scrollHeight + 'px' });
+            id.stopObserving('load').setStyle({ height: id.contentWindow.document.lastChild.scrollHeight + 'px' });
 
             // For whatever reason, browsers will report different heights
             // after the initial height setting.