我在与父/容器页面相同的域/协议内的iframe中加载aspx网页。Iframe中的内容有时比iframe本身更高。我不想在Iframe上显示滚动条。
我需要调整Iframe的高度基于包装'div‘标签内的aspx页面,iframe将包含。下面是我为实现这一点而编写的jquery:
$("#TB_window", window.parent.document).height($("body").height() + 50);
'TB_window‘-包含Iframe的div。
' body‘- iframe中aspx的body元素。
此脚本附加到iframe内容。我从父页面获取TB_window元素。虽然这在Chrome上运行得很好,但TB_window在火狐上就崩溃了。我真的很困惑/迷失了为什么会这样。
有没有人能给我一些建议,让我更好地处理这种情况?非常感谢您的帮助,谢谢
发布于 2013-06-07 05:11:49
你必须在你的iframe上使用管理一些事件
<iframe id="iframe" src="xyz" onload="FrameLoad(this);"
onresize="FrameLoad(this);" scrolling="no" frameborder="0">
</iframe>
function FrameLoad(ctrl) {
var the_height = ctrl.contentWindow.document.body.scrollHeight;
$(ctrl).height(the_height)
}
也可用于跨浏览器
document.domain = document.location.hostname;
在父页面和子页面中
发布于 2012-02-06 13:40:09
如果差别不是很大,你可以添加
overflow:hidden
添加到css类
这不会调整窗口的大小,但可能是您要搜索的内容。
https://stackoverflow.com/questions/9155634
复制