兼容各浏览器的iframe方法

方法一:(推荐1)

<iframe id="frame_content" src="/Home/CreateGroup?classID=@ViewBag.ClassID" scrolling="no" frameborder="0" height="100%" width="82%"></iframe>
<script type="text/javascript">
$("#frame_content").load(function () {
$(this).height($(this).contents().height());
})
</script>

方法二:

<iframe id="frame_content" src="/Home/GroupIndex?classID=@ViewBag.ClassID" scrolling="no" frameborder="0" onload="this.height=100" width="82%"></iframe>
<script type="text/javascript">
function reinitIframe() {
var iframe = document.getElementById("frame_content");
try {
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
} catch (ex) { }
}
window.setInterval("reinitIframe()", 200);
</script>

原文地址:https://www.cnblogs.com/ggbbeyou/p/2945712.html