Forum Moderators: open

Message Too Old, No Replies

scrollHeight & scrollWidth for iFrames

         

carlanga

1:04 am on Nov 8, 2002 (gmt 0)

10+ Year Member



I have a page that loads multiple iFrames, I need to be able to execute my script when the final scrollHeight and scrollWidth is available for each iFrame. I am using the onLoad event on the body of each iFrame.document.body to fire my function but it is too soon, I need to check that the scrollHeight is not 0 and setTimeouts appropiately. Is there an event that I can capture when the document has the final scrollHeigth ready?

tedster

7:14 am on Nov 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When do you scroll the iframe? Instead of using onLoad, it seems to me that you might call the script (2) after you call the scrolling for the iframe (1), in a 1-2 sequence. That way you can be sure the scrolling is executed without all kinds of timeouts and rechecking.

carlanga

7:32 am on Nov 8, 2002 (gmt 0)

10+ Year Member



I have a page that could load several iframes could be from 1 to 100 iframes.. or may be more. Each of those iframes start with a set width and height, in each iframe a different document is going to load.
What I need is to figure out the height and width of the document inside the iframe so that I can adjust the height and width of the iframe appropiatly (so that the entire document shows thru the iframe..no scrolling). I tried using different attributes in the document to give me the heigth and width, such as document.body.clientHeight etc etc .. however the one that gives me exactly what I need is document.body.scrollHeight and document.body.scrollWidth.
However, to fire my function to set the appropiate dimension of the iframe I use the onLoad event in the body of the document inside the iframe, unfortunately the height and width of the document in the iframe is 0, therefore I set time out till these values are not 0.

I never get to scroll the page, all I need is the dimensions of the document in the iframe as soon as is ready, and therefore my question .. is there an event that provides me that since the iframe document body onload happens too soon?

tedster

9:06 am on Nov 8, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have two things to share - maybe they can help.

First, are you sure your script is getting the scrollHeight object for the iframe document, and not for the parent document? It surprises me that the scrollHeight object would not be available when onLoad fires - after all, the onload event is all about the fact that the document and all its objects are now available.

Second, here's a page at Microsoft [msdn.microsoft.com] that diagrams the available measurement properties. Maybe something there can trigger a new idea.