SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Hybrid View

  1. #1
    SitePoint Enthusiast tjk's Avatar
    Join Date
    May 2006
    Location
    Melbourne, Australia
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

    Thanks in advance
    Tim

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've got it the wrong way round.
    Code:
    document.getElementById("table_id").style.display = "none";
    You want to set the display CSS property of the style attribute of an element.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Enthusiast tjk's Avatar
    Join Date
    May 2006
    Location
    Melbourne, Australia
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about that. It's been a longggg day.

    Aside from my error....any ideas?

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should work. Can you provide a link to the page in question?
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Enthusiast tjk's Avatar
    Join Date
    May 2006
    Location
    Melbourne, Australia
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Birnam wood is come to Dunsinane

  7. #7
    SitePoint Enthusiast tjk's Avatar
    Join Date
    May 2006
    Location
    Melbourne, Australia
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks AutisticCuckoo. I'll work through your advice and see how it goes.

    Much appreciated. Tim.

  8. #8
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi!

    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.

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @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.
    Birnam wood is come to Dunsinane

  10. #10
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    813
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    visibility == hidden will leave space where it was occupied by the element. It might not be as intended.

  11. #11
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're right. I understood the problem in the opposite way....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •