页面代码
<style>
.page {
width: 100%;
min-height:600px;
margin-top: 10px;
border: thick;
}
</style>
<div>
<iframe frameborder='0' border="0" scrolling='no' id="framContent" class="page" onload="setIframeHeight(this)"></iframe>
</div>
<script>
//设置iframe自适应
function setIframeHeight(iframe) {
if (iframe) {
var src = iframe.src;
var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
if (iframeWin.document.body) {
var bheight = iframeWin.document.body.scrollHeight;
var dheight = iframeWin.document.documentElement.scrollHeight;
var iframeheight = Math.min(bheight, dheight);
iframe.height = iframeheight;
}
}
};
</script>