There are many codes about iframes that are highly adaptable on the Internet, but they are quite messy, some are too complicated, and some have obvious errors. Yuxinsheng gave a modified streamlined version, which felt good. He simply corrected the error under Opera. The code is as follows:
JavaScript part:
<scripttype=text/javascript>
functionsetcwinheight(iframeobj){
if(document.getelementbyid){
if(iframeobj){
if(iframeobj.contentdocument&&iframeobj.contentdocument.body.offsettheight){
iframeobj.height=iframeobj.contentdocument.body.offsettheight;
}elseif(document.frames[iframeobj.name].document&&document.frames[iframeobj.name].document.body.scrollheight){iframeobj.height=document.frames[iframeobj.name].document.body.scrollheight;
}
}
}
}
</script>
html part:
<iframename=framecontentsrc=*frameborder=0width=100%onload=setcwinheight(this)></iframe>
Fill in the address of the iframe page where the number * is marked. It should be noted that the src address must be under the same website, otherwise there will be an error of permissions being prohibited.