Iframe, especially the iframe without borders, is possible to update part of the page data without refreshing a new page because it can be seamlessly integrated with the webpage, however, the size of the iframe is not as flexible as that of the layer, which makes it difficult to use it. It is not good to set the height of the iframe when it is too large or less. Now, let me tell you a way to dynamically adjust the height of iframe, mainly the following JS functions:
The Code is as follows:
Function SetWinHeight (obj)
{
Var win = obj;
If (document. getElementById)
{
If (win &&! Window. opera)
{
If (win. contentDocument & win. contentDocument. body. offsetHeight)
Win. height = win. contentDocument. body. offsetHeight;
Else if (win. Document & win. Document. body. scrollHeight)
Win. height = win. Document. body. scrollHeight;
}
}
}
Finally, add iframe and you cannot discard the onload attribute. Of course, the id must also be matched by win in the function.
Program code
The Code is as follows: