如何自动获取Iframe自动高度
js部分:
<script type="text/javascript">
function SetCwinHeight(iframeObj){
if (document.getElementById){
if (iframeObj && !window.opera){
if (iframeObj.contentDocument && iframeObj.contentDocument.body.offsetHeight){
iframeObj.height = iframeObj.contentDocument.body.offsetHeight;
}else if(document.frames[iframeObj.name].document && document.frames[iframeObj.name].document.body.scrollHeight){
iframeObj.height = document.frames[iframeObj.name].document.body.scrollHeight;
}
}
}
}
</script>
html网页部分
<iframe src="https://www.yiwangdajin.com" name="frameContent" scrolling="auto" frameborder="no" width="799" onload="SetCwinHeight(this)"></iframe>