Forum Moderators: open

Message Too Old, No Replies

I-frame resizing

problems with I-frame resizing

         

dhimahi1

5:46 pm on Jun 24, 2003 (gmt 0)



Can anybody help me with the problem of resizing i-frime according to the content that is loaded into it.

I wannt to make it work on as most browsers as possible. The code I am using does not work on IE 5 and Mac IE. Can I make it work. Does resizing of I-frames work in those browsers?

Where does work and where it doesen't?
Is there a good resource site where I can learn about resizing i-frame according to the content that is loaded into it.

Thanx

tedster

6:44 am on Jun 25, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've seen a few approaches to this challenge that work on the most modern browsers -- in fact a Google search turns up several. But I've never seen good cross-browser code.

However, IE 5.5 at least should be doable. What is the core of your approach? What seems to fall apart on the browsers and platforms you mention?

[edited by: tedster at 3:32 am (utc) on June 28, 2003]

AWildman

3:21 am on Jun 28, 2003 (gmt 0)

10+ Year Member



my solution was to have an onload function for each page that was loaded into the iframe.
Each page loaded into the iframe has a container div with an id. I use javascript to find the height of the div and add 50px for some graphics that appear above the div. In this way, I have the height of the entire contents of the page.
When I"m at work, I can put the code here if anyone is interested, but its pretty straightforward document.divname.clientHeight or document.divname.offsetHeight.

Malinali

8:26 pm on Jun 30, 2003 (gmt 0)



This script:

 function setHeight()
{
var body = yourIframeName.document.body
var frame = document.all("yourIframeName")
frame.style.height = body.scrollHeight +
(body.offsetHeight -
body.clientHeight)
}

works if you include it on the "mother" page, your iframe has a name you know, and you can add a call to the function on every other page's "onLoad" using document.parent.setHeight()