I've finally found a solution to my problem. setIframeHeight: function() { var innerDoc = (this.iframeElement.contentDocument) ? this.iframeElement.contentDocument : this.iframeElement.contentWindow.document; var h = innerDoc.body.scrollHeight; this.iframeElement.setStyle("height", h); }
should change to setIframeHeight: function() { this.iframeElement.setStyle("height", 1px); //new line added var innerDoc = (this.iframeElement.contentDocument) ? this.iframeElement.contentDocument : this.iframeElement.contentWindow.document; var h = innerDoc.body.scrollHeight; this.iframeElement.setStyle("height", h); } This is not a solution to the onbeforeonload event problem but a solution to the dynamic iframe problem.