I'm making an iframe. When the height is automatically adjusted, the code for the embedded page commit.asp is as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Related Comments </title>
<style type= "Text/css" >
<!--
Body {
margin-left:0px;
margin-top:0px;
margin-right:0px;
margin-bottom:0px;
}
-->
</style>
<body bgcolor= "Transparent" onload= "zoomiframe ();" >
</body>
<script language=javascript>
<!--frame page automatic sizing-->
function Zoomiframe ()
{
Parent.document.getElementById ("Comment_load"). Style.height=document.documentelement.scrollheight;
}
</script>
Then insert other code on the other page and embed the page in another page
<iframe src= "comment.asp?classid=2&id=12" allowtransparency= "true" Name= "Comment_load" "width=" 540 "height=" "marginwidth=" 0 "marginheight=" 0 "align=" Middle "scrolling=" no "frameborder=" 0 "></iframe>
But no effect, the IFRAME can not automatically adjust the height of the content.
Later I added an alert (document.body.scrollHeight) to Zoomiframe (). The value of bouncing out is 0, but if you run commit directly. The height of the ASP popup is consistent with the content.
I really don't understand where there is a rush. I used to do this, I do not know whether the forum has encountered such a problem.
Thank you!
Copy Code code as follows:
Parent.document.all ("Comment_load"). Style.height=document.body.scrollheight| | Document.documentElement.scrollHeight;
Try it, there should be no problem.
<script type= "Text/javascript" >
<!--
Onload=function ()
{
Parent.document.getElementById (' AC '). style.height= "200px";
}
-->
</script>
<iframe src= "comment.asp?classid=2&id=12" allowtransparency= "true" Name= "Comment_load" "width=" 540 "height=" "marginwidth=" 0 "marginheight=" 0 "align=" Middle "scrolling=" no "frameborder=" 0 "></iframe>
Add an id attribute
PS: If you add the following headers to your Web page
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
You have to use Document.documentElement.scrollHeight to do something about it.
If there is no document declaration to use
Document.body.scrollHeight