The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

display.style in Firefox

Hi all,

I'm having trouble with a display.style reference displaying correctly in Firefox (Mac, not sure about PC yet). The page calls a javascript function upon loading that is supposed to hide one of two tables on the page. Whilst it does hide the table as asked - there is an empty space where the table would have been.

My understanding is that if display.style = 'none'; then the surrounding page content should contract to fill the space of the hidden element. Is this correct?

My javascript function for the hidden effect is:

Code:

document.getElementById('table_id').display.style = 'none';

Has anyone come across this problem in Firefox before? It seems to work fine in Safari.

There are 44 validation errors on that page, some of which are quite serious. Always make sure that the markup is valid before you start looking for presentational issues.

You have a FORM element as an immediate child of a TABLE. Who knows how this mucks up the DOM tree and the rendering in Firefox?

Fix the validation problems and see if that helps. If not, post back and we'll see what it could be.

BTW, you should probably use an HTML doctype rather than XHTML. If not, you should learn about the differences between XHTML vs HTML. Remember that XHTML is case-sensitive, so you can't write attribute names as onLoad etc.

@bosko: using visibility="hidden" will cause the very same effect that Tim is seeing now, and which is undesirable. He's right in using display="none", but he needs to fix the markup errors to make it work properly.