跨域iframe自动调整高度 [英] cross domain iframe adjust height automatically

查看:100
本文介绍了跨域iframe自动调整高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了谷歌以及几个来自stackoverflow的答案,但没有一个解决方案为我工作。是否有任何工作解决方案可用,

非常感谢您

Rohit。

解决方案

IFRAME需要将主体大小发送给主页。



对于现代浏览器可以使用IFRAME中的 parent.postMessage ,并在主页面中有一个监听器来接收该值并调整IFRAME的大小。



对于较老的浏览器,您可以使用技巧来传递数据,即通过 windows.name window.location.hash
但使用这些技巧,您必须轮询 setInterval 来检查更改。


I searched over google as well as few answers from stackoverflow but none of teh solution worked for me. Is there any working solution available ,

Thanks you very much

Rohit.

解决方案

The IFRAME need to send to the main page its body size.

For modern browsers you can use parent.postMessage from the IFRAME and have a listener in the main page to receive the value and resize the IFRAME.

For older browsers you can use tricks like passing data i.e. through windows.name or the window.location.hash But with those tricks you will have to poll with a setInterval to check for changes.

这篇关于跨域iframe自动调整高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆