Found the following js
function SetCwinHeight(obj)
{
var cwin=obj;
if (document.getElementById)
{
if (cwin && !window.opera)
{
if (cwin.contentDocument && cwin. contentDocument.body.offsetHeight)
cwin.height = cwin.contentDocument.body.offsetHeight 20;
else if(cwin.Document && cwin.Document.body.scrollHeight)
cwin.height = cwin.Document .body.scrollHeight 10;
}
}
}
Then...
Enter the test process (the call is very simple, skip it first)
1 .IE --- Passed, but there is still a slight difference in height, very small, and the scroll bar is still there
2.FF --- Passed, same as IE, but there is a small gap
3.Opera --- Look at that JS You will know if the conditions are passed
but mainstream browsers must at least pass these three items! ! !
So, Google
searched for the special phenomena of each browser when processing document.scrollHeight or offsetHeigth
and found that when the Opera browser processes iframe content, it uses contentWindow
to process the content. When the height is high, it is consistent with IE
Thus, we have the following js
<script> <br>function SetCwinHeight(obj) <br>{ <br>var cwin=obj; <br>if ( document.getElementById) <br>{ <br>if (cwin && !window.opera) <br>{ <br>if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight) <br>cwin.height = cwin. contentDocument.body.offsetHeight 20; //FF NS <br>else if(cwin.Document && cwin.Document.body.scrollHeight) <br>cwin.height = cwin.Document.body.scrollHeight 10;//IE <br>} <br>else <br>{ <br>if(cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight) <br>cwin.height = cwin.contentWindow.document.body.scrollHeight;// Opera <br>} <br>} <br>} <br></script>
In this way, these three views are finally viewed The browser has adapted
As a programmer, you still have to be more careful
and test again
OK... All three browsers display normally, and there is no vertical scroll bar of the iframe.