关于如何动态更改 iframe 高度有很多答案。 我尝试了插件 https://github.com/house9/jquery-iframe-auto-height
该插件适用于 iframe 加载,但是,如果内容不重新加载(例如 ajax),高度不会根据 iframe 内容内的变化动态变化。
我的问题是:如何随着内容高度的变化动态改变 iframe 的高度?
最佳答案
Edit... Ok, my friend told me right way. I removed plugin from main window and added to iframe page this jquery code:
_
setInterval(function(){
//console.log($("body").height());
parent.$("iframe").height($("body").height());
}, 100);
but there is problem, that after expanding, height does not change to its first state. It grows bigger, but does not goes smaller if i close accordeon at example... This problem is only in Chrome browser...
Looks like it's Chrome bug, because if you try to resize Chrome window iframe goes back to normal height. On IE9 and FF12 works fine.
关于jquery - 根据内容动态调整iframe高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10576005/