No replies
CSSelgreco1965's picture
Last seen: 9 years 15 weeks ago
Timezone: GMT+3
Joined: 2004-06-13
Posts: 51
Points: 28

I am doing two websites. Basically I am designing them, setting up the basic dhtml, styling, etc. Not a great programmer. Am an artist Smile
Anyway, these two sites have iframes. Both of which have a child URL from an external site. One being Amazon. The other being a subscription form.
However, what I have noticed, especially on the Amazon one, due to their coding, its 4000px high. This stretches the page to a stupid level.
What I would like to know is, is their any script/solution that can make the iframe resize to the content.
I was looking on the web, and found many possibles. However, these only worked locally, and not when placed on the server.
Here is one example:


The solution I settled on works like this:
The parent page has a javascript function like this:

function insertIt() {
var _y = document.getElementById('framediv');
var _x = window.frames[0].document.body.innerHTML;
_y.innerHTML = _x
Then, the parent page has a div with the id "framediv" which is placed where the contents of the iframe should appear on the page.
The iframe element is then placed inside the div, like this:

As you can see, there's onload="insertIt()" inside the iframe element. So when the iframe loads, the parent page immediately takes the contents of the body of the document contained in the iframe and actually replaces the iframe element with thatcontent.

It's a little tricky to comprehend, but it works great.

You said you're a newbie, does this make any sense to you?

also, is the iframe document located on the same server and the same domain as the parent page?
That will play a part.

Any help at all?? Thanks in advance

The web becomes a tangled mess when Microsoft gets involved!