我正在开发类似iGoogle的应用程序.来自其他应用程序(在其他域上)的内容使用iframe显示.
如何调整iframe的大小以适应iframe内容的高度?
我试图破译谷歌使用的javascript,但是它被混淆了,到目前为止搜索网络已经没有结果.
更新:请注意,内容是从其他域加载的,因此适用同源策略.
我有一个帮助页面,help.php,我加载一个iframe里面main.php我怎样才能得到这个页面的高度,一旦它在iframe中加载?
我问这个是因为我无法将iframe的高度设置为100%或auto.这就是为什么我认为我需要使用javascript ..我正在使用jQuery
CSS:
body {
margin: 0;
padding: 0;
}
.container {
width: 900px;
height: 100%;
margin: 0 auto;
background: silver;
}
.help-div {
display: none;
width: 850px;
height: 100%;
position: absolute;
top: 100px;
background: orange;
}
#help-frame {
width: 100%;
height: auto;
margin:0;
padding:0;
}
Run Code Online (Sandbox Code Playgroud)
JS:
$(document).ready(function () {
$("a.open-help").click(function () {
$(".help-div").show();
return false;
})
})
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class='container'>
<!-- -->
<div class='help-div'>
<p>This is a div with an iframe loading the help page</p>
<iframe id="help-frame" src="../help.php" …Run Code Online (Sandbox Code Playgroud)