We are providing HierMenus to you at no cost. HierMenus code requires a confirmed membership with internet.com. Please register by clicking here and come back soon to download your free copy of HeirMenus code.
Click Here to Register

Site Navigation
Bulletins
About
Documentation
FAQ
Samples
Known Issues
Technology Jobs

internet.commerce

Partner With Us














          
internet.com

IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

 
HierMenusCentral Enhance the Functionality of Your Web Site with DHTML HierMenus.
    

home / issues / issue #3

Issue:Menu creation adds whitespace to bottom of page
Browser:IE5.5/IE6
Platform:Windows
Description:When creating a menu in IE5.5 and 6, a small amount of whitespace may be "added" to the bottom of the HTML page. This whitespace appears even though HM specifically creates menus as hidden objects well off the left (and, in later versions, top) edge of the page.
Cause:Unknown. This appears to be a bug in the browser. In our original analysis, we theorized that the space was the result of IE5.5/6 always adding a small amount of white space to the bottom of the document whenever the last element of the page (the body's lastChild) was an absolutely positioned element. However, a reader has suggested a simpler and more likely cause: If there is a defined element on the page that follows the last visible element of the page, the margin-bottom of the last visible element of the page will be displayed in full. Or in other words, even though our menus are defined as absolutely positioned elements and are physically displayed elsewhere on the page, they are created as children of the body element after the last visible element of the page; and that last visible element is then displayed with its full margin allotment.

Or, to put it another way, IE5.5/6 does not display the bottom margin on the last child of the page (the last element actually created as a child of the body element of the page). Thus, the addition of the menus appears to "create" whitespace on the page, since the menus are added after the last element of the page, which in turn trigger the margin display on the last item.

To see what we're talking about, have a look at these three sample pages, none of which even use any JavaScript:

Absolutely Positioned Div On Bottom
Absolutely Positioned Div On Top
Absolutely Positioned Div On Bottom (with margin-bottom 0px)

Load the first page in IE5.5 or 6, then shrink the browser window until just before the vertical scrollbar would appear. Then load the second page into the same window without resizing it. On the second page, you'll notice your vertical scrollbar appears, even though the page contents should be identical (the only difference being a hidden, absolutely positioned object at (0,0) which, in the first page is defined at the beginning of the document and in the second page is defined at the end of the document). On the third page, the last h1 is specifically set to margin-bottom of 0px via the page's style sheet; notice that that page is displayed just like the first example, even though the absolutely positioned div is on the bottom of the page.

In HierMenus this space virtually always appears, since HM always creates menus at the end of the page (via appendChild) and page authors would rarely think to explicitly force the margins to be 0 on the last visible element of the page.

The above explanation leads us to two possible work arounds: change the HierMenus code to use insertBefore instead of appendChild; or setup your pages such that the last visible element of the page is always forced to have a margin-bottom of 0px.

Comments:As noted above, we see this problem partially because we use appendChild to add menus to the HTML document. When using insertBefore instead (this is the code workaround we mentioned above) the problem goes away (even though we are inserting/appending the exact same element). However, removing the margin display on the last visible item of the page using CSS directives (for example, <h1 style='margin-bottom:0px'> provides a much cleaner workaround since it does not require code adjustments and is therefore our generally recommended fix.

Other suggestions are requested. Please use this link to send mail if you have any insights and would like to share them:

Internet Explorer White Space

Posted:March 18, 2004

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Created: 3/25/2004
Updated: 10/18/2004
URL: http://www.hiermenuscentral.com/issues/3.html