function setIframeHeight(iframe) {
if (iframe) {
var subWeb = document.frames ? document.frames["menuFrame"].document : iframe.contentDocument;
if (iframe != null && subWeb != null) {
$("#menuFrame").height(0);// 清除上一个子页面高度的影响
$("#menuFrame").height(subWeb.body.scrollHeight);
// $("#menuFrame").width(1515);//
// $("#menuFrame").width(subWeb.body.scrollWidth);
}
}
};
<iframe id="menuFrame" name="menuFrame" src="" style="background: transparent"
onload="setIframeHeight(this)"
scrolling="no" frameborder="0" height="600px" width="100%"></iframe>
window.onload = function () {
setIframeHeight(document.getElementById('menuFrame'));
};
//页面窗口改变之后自动计算下iframe的高度 guanhongchang
window.onresize = function(){ setIframeHeight(document.getElementById('menuFrame'));}
var menuFrame = parent.window.document.getElementById('menuFrame')
parent.window.setIframeHeight(menuFrame);