Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top