resize iframe to size of contents
-
I would like to resize an iframe to the offsetWidth and offsetHeight of the contents in the iframe. However, It requires me to set a timeout so that the offset sizes can be determined. If I dont set a timeout, it seems that IE has not fully deteremined the offset sizes and therefore the iframe gets sized to be too small. Especially when there are images in the contents of the iframe. But if I wait one second, IE has by then rendered everything and it knows the actual offset sizes of the contents of the iframe. This seems like a horrible way to achieve this functionality. Is there any javascript event that fires once the actual layout has been determined? function ResizePage(WaitASec) { if (window.frameElement) { if (WaitASec) { window.setTimeout("ResizePage(false);", 1000); return; } window.frameElement.style.height = document.getElementsByTagName('div')[0].offsetHeight; window.frameElement.style.width = document.getElementsByTagName('div')[0].offsetWidth; } }
-
I would like to resize an iframe to the offsetWidth and offsetHeight of the contents in the iframe. However, It requires me to set a timeout so that the offset sizes can be determined. If I dont set a timeout, it seems that IE has not fully deteremined the offset sizes and therefore the iframe gets sized to be too small. Especially when there are images in the contents of the iframe. But if I wait one second, IE has by then rendered everything and it knows the actual offset sizes of the contents of the iframe. This seems like a horrible way to achieve this functionality. Is there any javascript event that fires once the actual layout has been determined? function ResizePage(WaitASec) { if (window.frameElement) { if (WaitASec) { window.setTimeout("ResizePage(false);", 1000); return; } window.frameElement.style.height = document.getElementsByTagName('div')[0].offsetHeight; window.frameElement.style.width = document.getElementsByTagName('div')[0].offsetWidth; } }