JavaScript native and jquery libraries implement IFRAME adaptive content height and width---recommend using jquery Code!
<iframe src= "index.php" id= "Mainiframe" name= "Mainiframe" width= "100%" frameborder= "0" scrolling= "no" marginwidth= "0" marginheight= "0" ></iframe>
The code based on the jquery library is well implemented:
<script language= "javascript" type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#mainframe" The. Load (function () {
$ (this). Height (0);//To control the height of the iframe for each refresh initialize
var height = $ (this). Contents (). Height () +;
$ (this). Height (height < 500:height);
}
); </script>
Based on the implementation of JS native code:
<script language= "JavaScript" >
if (window.parent.length>0) { Window.parent.document.all.mainframe.style.height=document.body.scrollheight;}
</script>
Just add the above paragraph to the file </body> after you've been called by the IFRAME!
This can also control the height of the iframe to grow automatically with the content.
<iframe name= "web" width= "100%" frameborder=0 height= "100%" src= "index.php" id= "web" onload= "this.height= Web.document.body.scrollheight+20 "></iframe>
The jquery library realizes the adaptive content height and width of iframe