Firefox iframe adaptive height and bug

Source: Internet
Author: User

In Firefox and IE, enable IFRAME to adapt to highly-adaptive JS functions, as well as Bugs caused by CSS settings on IFRAME pages.
Suitable for javascript with adaptive height of IE and Firefox Code :
View plaincopy to clipboardprint?
Function turnheight (IFRAME)
{
VaR FRM = Document. getelementbyid (IFRAME );
VaR subweb = Document. frames? Document.frames[iframe].doc ument: FRM. contentdocument;
If (FRM! = NULL & subweb! = NULL)
{Frm. Height = subweb. Body. scrollheight + 20 ;}
}
Function turnheight (IFRAME)
{
VaR FRM = Document. getelementbyid (IFRAME );
VaR subweb = Document. frames? Document.frames[iframe].doc ument: FRM. contentdocument;
If (FRM! = NULL & subweb! = NULL)
{Frm. Height = subweb. Body. scrollheight + 20 ;}
}
Call method:
View plaincopy to clipboardprint?
<IFRAME id = iframe1 onload = "turnheight ('iframe1 '); "Height =" 100% "src =" framepage1.html "frameborder = 0 width =" 101% "scrolling = NO> </iframe>

Note: The float attribute and display attribute cannot be used for elements on the IFRAME page. Otherwise, the obtained IFRAME height in Firefox is 0, leading to adaptive height failure.
This article comes from the tornado Information Network http://www.ljf.cn/; original address: http://www.ljf.cn/2010/2/Item231560.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.