开发者

Having a child page resize parent without invoking parent hosted script?

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜