display.style in Firefox
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?
Has anyone come across this problem in Firefox before? It seems to work fine in Safari.
document.getElementById('table_id').display.style = 'none';
Thanks in advance
You've got it the wrong way round.
You want to set the display CSS property of the style attribute of an element.
document.getElementById("table_id").style.display = "none";
Sorry about that. It's been a longggg day.
Aside from my error....any ideas? :)
It should work. Can you provide a link to the page in question?
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.
Thanks AutisticCuckoo. I'll work through your advice and see how it goes.
Much appreciated. Tim.
I'm pc user. I think this is not browser issue. Try to use ...style.visibility = 'hidden'; instead style.display = 'none';
Visibility will just hide the table, not remove it.
@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.
visibility == hidden will leave space where it was occupied by the element. It might not be as intended.
You're right. I understood the problem in the opposite way....