javascript - Bootstrap Modal - 根据 iframe 高度调整模态大小

标签 javascript jquery html twitter-bootstrap iframe

<分区>

我需要根据 iframe 内容的高度调整此 bootstrap 模态的大小,因为它是动态的。

使用 onload 和以下函数我什么也没得到。

window.resizeIframe = function () {
         var frame = $('#custom-frame');
         var modalHeight = $('#custom-frame').contents().height();
         frame.height(modalHeight);

         $(window).resize(function() {
            frame.height(modalHeight);
         });
      };

我提供了一个 plunker: http://plnkr.co/edit/eElqXJwvxmpc1XMrdwIK?p=preview

最佳答案

除非您使用 height 显式设置它属性(你没有做), <iframe> 的高度默认为 150px。在设置模态高度之前,您需要设置 <iframe>高度。 this question中的一些信息.

关于javascript - Bootstrap Modal - 根据 iframe 高度调整模态大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21438823/

相关文章:

javascript - jQuery 查找具有一个数据键和多个值的数据属性

javascript - SetAttribute 在 IE 中不起作用

javascript - 将数据从 XWalkView 传递到原生 Android

javascript - 将变量值从 if 语句传递到 if/else 之外

javascript - 将 Excel 列字母表(例如 AA)转换为数字(例如 25)

javascript - Promise catch 未在测试中被捕获

javascript - 提交 $_GET 表单来创建漂亮的 URL

javascript - 对多个组合框使用相同的 ID?

javascript - 如何使用 vue js 在提交时将表单数据保存在 .yml 文件中?

jQuery Mobile Listview 长项