views:

20

answers:

1

I currently have two html pages, a server hosted page, and a client hosted page, both on the same domain.

The server page, has an iframe sourcing the client page.

I want the parent page iframe to resize based on the child pages content. To accomplish this I have a bit of javascript that sits on both pages. The client(child) page determines it's dimensions, then invokes a function defined on the parent page which resizes the iframe (it's very possible to have this same script sit only on the parent page to accomplish this...).

Is it possible for the client page to directly resize the iframe of the parent without invoking parent script?

As we are the owner of the client page, if we can isolate this code to the child page, it makes having to change any code much less painful.

+1  A: 

Yes; you can use the window.frameElement property in the child page to get the <iframe> element in the parent page that hosts the child page.

Thus, you can move the resizing code from the parent page to the child page and resize window.frameElement.

SLaks
+1 You sir, are a scholar, and a gentleman.
Alan
@Alan: Then you should accept this answer
SLaks
Don't worry, SLaks, I will. I usually wait 24-hours before accepting answers.
Alan
What is the advantage of this approach over something like `parent.document.getElementById('myIframeId')` ?
Alan