How can I set the height for iFrame content when content of the iframe is an asp.net site with master page ?
Does anyone know any jQuery plug in ?
Update This works fine in IE but fails in chrome and firefox
function resizeFrame(f) { f.style.height = f.contentWindow.document.body.scrollHeight + "px"; }
Calling it on body onload()
body onload="resizeFrame(document.getElementById('MainIFrame'))"
iframe code
<iframe id="MainIFrame" class="autoHeight" runat="server" marginwidth="0" style="margin: auto; "
frameborder="0" width="100%" scrolling="no" >
</iframe>
Script Works for all Browsers
<script type="text/javascript" language="javascript">
function resizeIframe(dynheight) {
try {
var f = document.getElementById("autosizeframe");
document.getElementById("autosizeframe").height = parseInt(dynheight) + 10;
if (f.contentDocument) {
f.height = f.contentDocument.documentElement.scrollHeight + 30; //FF 3.0.11, Opera 9.63, and Chrome
} else {
f.height = f.contentWindow.document.body.scrollHeight + 30; //IE6, IE7 and Chrome
}
}
catch (err) {
alert('Err: ' + err.message);
window.status = err.message;
}
}
window.onload = function() {
var height = document.body.scrollHeight;
resizeIframe(height);
};
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.