iframe高度自适应

//设置iframe高度自适应
function setWinHeight(obj){
var win = obj;
if (document.getElementById) {
if (win && !window.opera) {
if (win.contentDocument && win.contentDocument.body.offsetHeight) {
win.height = win.contentDocument.body.offsetHeight;
} else if (win.Document && win.Document.body.scrollHeight) {
win.height = win.Document.body.scrollHeight;
}
}
}
}

---------------------------------------------------------------------
//iframe内容改变时同时改变iframe高度
function reinitIframe(){
var iframe = document.getElementById("livereport");
try {
var h = iframe.contentWindow.document.documentElement.scrollHeight;
if (h < 10) {
h = 10;
}
iframe.height = h;
$("#searchContent").jscroll({W:"7px",Bar:{ Pos:"middle"},Btn:{btn:false}});
} catch (ex) {
iframe.height = 10;
}
}

你可能感兴趣的:(iframe)