jquery - 根据内容动态调整iframe高度

标签 jquery ajax iframe height computed-style

关于如何动态更改 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/

相关文章:

PHP jQuery Chat - 用户正在输入功能

javascript - 使完美的滚动条默认可见

javascript - 如何以编程方式将内容脚本添加到 iframe 文档

javascript - 收集多个数据并在 laravel 中通过 ajax 发送

html - iFrame 高度自动 (CSS)

php - iframe 中的 laravel 应用程序不断刷新 session

javascript - 将图像从 JQuery 上传到 Node JS

jQuery 选择器和一个错误

javascript - 如何使用ajax动态更改编辑路径的href

jquery - 为什么 JQuery 中 'replaceWith' 函数上的数据没有被完全替换?