html片段:
<div style="width:360px;height:100%;background:#ccc" class="panel-body">
<iframe id="pcontframe" name="pcontframe" src="" width="100%" height="100%" frameborder="0" scrolling="no">
</iframe>
</div>
js代码:
iframeHeight = function() {
var ifm = document.getElementById("pcontframe");
if (ifm != null) {
try{
var bHeight = ifm.contentWindow.document.body.scrollHeight;
var dHeight = ifm.contentWindow.document.documentElement.scrollHeight;
var height = Math.min(bHeight, dHeight);
ifm.height = height+10;
}catch (ex){}
}
}
document.getElementById("pcontframe").onload = function() {
document.getElementById("pcontframe").height=100;
setTimeout('iframeHeight()',200);
};