IFRAME-related. The scrolling attribute of the IFRAME element in each browser is different from that of the subpage HTML and BODY element 'overflow '.

Source: Internet
Author: User
Document directory
  • Knowledge Base
  • Related Questions

Reprinted: http://www.w3help.org/zh-cn/causes/RX9009

Standard Reference

According to the description in the HTML4.01 standard, the FRAME element and IFRAME element have a special attribute "scrolling", which specifies the scrolling information for the FRAME window. The value may be:

  • Auto: the default value, indicating that the client provides a rolling device for the frame window when necessary;
  • Yes: indicates that the client always provides a rolling device for the frame window;
  • No: indicates that the client does not provide a rolling device for the frame window.

However, the specification does not indicate the constraint between this attribute and the scroll bar generated by the HTML element or BODY element in the Child pages introduced by the framework through the 'overflow' feature of CSS.

For more information about scrolling attributes, see section 16.2.2 The FRAME element in HTML4.01.

 

Problem description

InIE Chrome Safari"Overflow: hidden" of the HTML element of the Child page introduced by the IFRAME element will invalidate the scrolling attribute of the IFRAME element, and the IFRAME element will not display a scroll bar.

InChrome SafariIn, although the scrolling attribute of the IFRAME element is "no", if the 'overflow' attribute of the HTML or BODY element of its child pages is 'scroll ', the IFRAME will still be rendered to the scroll bar.

Impact

The differences between the scrolling attribute of the IFRAME element of each browser and the constraint between the HTML and the 'overflow' feature of its child pages may cause rendering differences of the Child page scroll bar.

Affected browsers
All browsers  
Problem Analysis

First, observe the situation when the HTML and BODY elements of the Child page are "overflow: scroll.

Analyze the following code:

Parent_scroll.html

<!DOCTYPE html><iframe src="sub1.htm" scrolling="yes" style="width:80px; height:80px;"></iframe><iframe src="sub1.htm" scrolling="no" style="width:80px; height:80px;"></iframe><br /><iframe src="sub2.htm" scrolling="yes" style="width:80px; height:80px;"></iframe><iframe src="sub2.htm" scrolling="no" style="width:80px; height:80px;"></iframe>

Sub1.htm

<!DOCTYPE html>

Sub2.htm

<!DOCTYPE html>

The home page contains four IFRAME elements. The scrolling attribute values in each group are "yes" and "no ". SubpageSub1.htmThe 'overflow' feature of the HTML and BODY elements in is 'scroll '. SubpageSub2.htmThe 'overflow' feature of the BODY element in is 'scroll '.Root elements in IE6 (Q) IE7 (Q) IE8 (Q) hybrid mode are not special effects caused by HTML.

The effect of each browser is as follows:

IE7 (S) IE8 (S) Firefox Opera Chrome Safari

Before analyzing the above group, run it separately in each BrowserSub2.htm, We can see:

  • InIE7 (S). The scroll bar generated by "overflow: scroll" of the BODY element has nothing to do with the page scroll bar;
  • InIE8 (S) Firefox Chrome Safari OperaWhen the 'overflow' feature of an HTML element is 'visable', the "overflow: scroll" generated by the BODY element serves as the page's scroll bar.

Return to the test code above. You can see:

  • InIE8 (S) Firefox OperaWhen the scrolling attribute is "no", it will interfere with the generation of the page scroll bar of its child pages, even if the 'overflow' attribute of the HTML element is invalid, or the HTML element overflow: the 'overflow' feature of the BODY element is invalid when visible;
  • InIE7 (S)In, although the visual effect is different from the preceding browser, the effect of scrolling attribute interference is the same, but only the 'overflow' feature of HTML elements is invalid;
  • InChrome SafariThe scrolling attribute "no" does not affect the 'overflow' feature of the HTML and BODY elements on the subpage.

Next we will continue to observe the situation when the HTML and BODY elements of the subpage are "overflow: hidden.

Analyze the following code:

Parent_hidden.html

<!DOCTYPE html><iframe src="sub.htm" scrolling="yes" style="width:80px; height:80px;"></iframe>

Sub.htm

<!DOCTYPE html>

The scrolling attribute value of the IFRAME element on the home page is "yes ". The 'overflow' features of the HTML and BODY elements of the Child pages are 'hidd' and 'scroll 'respectively '.

The effect of each browser is as follows:

IE7 (S) IE8 (S) Firefox Opera Chrome Safari

The Special Phenomenon in IE6 IE7 is still ignored. It can only be seen from the effect of the scrolling attribute on the scroll bar,

  • InIE Chrome SafariIn, although the scrolling attribute value of IFRAME is "yes", the "overflow: hidden" of the HTML element of the Child page causes the scroll bar of IFRAME to disappear;
  • InFirefox OperaThe child page scroll bar generated by the scrolling attribute of IFRAME is not affected by the "overflow: hidden" of the HTML element.

Summary:

  • InChrome Safari', Or the child page scroll bar when the 'overflow' element of HTML and BODY is 'visable. If the 'overflow' feature is set separately for the HTML and BODY elements of a child page, the constraints of the scrolling attribute on the Child page scroll bar are easily broken.
  • InFirefox Opera, If you set the 'overflow' feature for the Child page HTML and BODY elements separately, the Child page scroll bars generated and hidden by the scrolling attribute are not damaged.
  • InIEWhen the HTML element 'overflow' of the child page is 'hidd ',Chrome. When its 'overflow' is another value, it is similarFirefox.
Solution

The W3C specification does not indicate that the scrolling attribute should control the generation of the scroll bar or the 'overflow' feature of the element on the Child page. To prevent excessive scroll bars from appearing in the IFRAME subpage of Chrome Safari in some situations, avoid setting overflow: scroll for HTML or BODY elements.

See Knowledge Base
  • ...
Related Questions
  • ...
Test Environment
Operating system version: Windows 7 Ultimate build 7600
Browser version: IE6 IE7 IE8 Firefox 3.6.2 Chrome 5.0.360.0 dev Safari 4.0.5 Opera 10.51
Test page: Parent_scroll.html parent_hidden.html
Updated in this article: 2010-06-24

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.