Antecedent: A project for statistical effect, the Consultation page window embedded into a separate empty page, in this page Riga a statistic, let people look at this page with direct access to the consultation page, lazy toss what JS, directly with CSS to get under, fortunately the demand is not too high. It's OK.
Consequences: Because of the little contact with the IFRAME, almost useless, so at that time on Google, Baidu, also do not remember what was found at that time what content, anyway, the demand is not too strong, directly with CSS to solve
<! DOCTYPE html>
Visual looks like the table removed is also can drop, no test of OH.
Here are two ways to do it. One is placed on the same page as the IFRAME, one is placed on the test.html page.
Be careful not to put the wrong place.
IFRAME code, note to write ID
<iframe src= "test.html" id= "main" width= "M" height= "" frameborder= "0" scrolling= "Auto" ></iframe>
jquery Code 1:
//NOTE: The following code is placed in the test.html call
$ (window.parent.document). Find ("#main"). Load (function () {
var main = $ (window.parent.document). Find ("#main");
var thisheight = $ (document). Height () +30;
Main.height (thisheight);
});
jquery Code 2:
Note: The following code is placed on the same page as the IFRAME call
$ ("#main"). Load (function () {
var mainheight = $ (this). Contents (). Find ("Body"). Height () +30;
$ (this). Height (mainheight);
});
HTML code:
<iframe src= "http://www.111cn.net/" id= "Iframepage" name= "Iframepage" frameborder=0 "Scrolling=no" width= "100%" Onload= "Iframeheight ()" ></iframe>
JavaScript code:
<script type= "Text/javascript" JavaScript ">
function Iframeheight () {
var ifm= document.getelementbyid (" Iframepage ");
var subweb = document.frames document.frames["Iframepage"].document:ifm.contentdocument;
if (IFM!= null && subweb!= null) {
ifm.height = subWeb.body.scrollHeight;
}
}
</script>