根据内容设置 iFrame 宽度和高度
Set iFrame width and height based on content
目前我有一个jquery iframe模式对话框,可以打开一个ASPX页面。此页面包含另一个带有jQuery的iFrame。 内容 iframe 没有设置任何高度或宽度,因此根据内部内容的大小调整大小。 外部 jQuery iframe 模态不会根据其中的内容 iframe 调整大小。这是打开模态的代码:
function openModal() {
var horizontalPadding = 30;
var verticalPadding = 30;
var jqurl = "ContentPage.aspx";
var title = "Modal Title";
jQuery('<iframe scrolling="no" id="cLaunch" class="cLaunch" src="' + jqurl + '" frameborder="0"/>').dialog({
title: title,
modal: true,
resizable: true,
position: ['center', 50],
fluid:true,
overlay: {
opacity: 0.5,
background: "grey"
}
});
}
setInterval(function () {
document.getElementById("cLaunch").style.width = document.getElementById("cLaunch").contentWindow.document.documentElement.scrollWidth + 30 + 'px';
document.getElementById("cLaunch").style.height = document.getElementById("cLaunch").contentWindow.document.body.scrollHeight + 'px';
}, 1000)
连接页面.aspx:
<iframe name="contentloader" id="contentloader" frameborder="0" scrolling="no"></iframe>
任何帮助将不胜感激。
尝试根据 iframe 内加载的内容设置 iframe 的宽度和高度
$("#cLaunch").load(function() {
$(this).height( $(this).contents().find("body").height());
$(this).width( $(this).contents().find("body").width());
});
相关文章:
- 获取iframe内容的宽度-高度
- 使用javascript设置iframe的高度
- iframe上的100%自动高度
- 设置iFrame的高度
- 调整追加的 iframe 的高度
- 动态增加 iframe 高度
- 调整不同域上iframe的高度
- iframe高度100%不起作用
- 多个页面 iframe,高度加载
- 当内容显示在FireFox的iFrame中时,jQuery高度问题
- 加载新内容时调整iframe的高度
- 动态iframe高度-似乎需要重新加载页面
- 如何告诉 iframe 将图像链接调整为给定的宽度和高度
- 根据提交单击动态调整 iFrame 的高度
- 根据内容设置 iFrame 宽度和高度
- 如何更改其内容的 Iframe 高度(两者都来自同一域)
- 更改花式框iframe的大小-我可以更改宽度,但不能更改高度
- iFrame 不会扩展到完整的内容高度,即使有 jQuery 脚本以它为目标
- 同位素布局中的动态iframe高度
- iFrame - 在 iFrame 中更改内容时自动设置高度