Results 1 to 4 of 4

Thread: IE != FF after innerHTML = ""

  1. #1
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Red face IE != FF after innerHTML = ""

    Please feel free to razz me if this is a totally noob question and I should be doing browser detection and such to handle this situation. Hopefully the answer is simpler than that.

    I want to show a list of items and if the user clicks an item, show some text. So the HTML includes a <div id="xxx"></div> after each item, with CSS visibility: hidden and onclick I update the div's innerHTML with the text and visibility to visible. So far so good.

    When the user clicks again I want to remove the text and revert to the previous display; I set innerHTML="" and visibility: hidden. This works fine on Firefox but on IE a blank line is left. I tried setting top and bottom margins to 0 but that had little effect.

    So, what am I doing wrong?

    Thanks,
    Bill

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Odd, if the innerHTML is set to "" the visibility property shouldn't make any difference. Visibility hidden is supposed to leave a spot there for the element even though you cannot see it. The problem may be using the division tag which carries with it block level spacing (line break before and after). You might have better luck using a span tag which displays inline. Failing that, you might want to experiment with the element's display property instead of its visibility property, values for display that would apply to this situation are none, block and inline.

    PLEASE: Include the URL to your problematic webpage that you want help with.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John,

    Thanks for the answer. I of course mucked things up implementing it at first but in the end switching to span and display from div and visibility did the trick. For now I'd prefer not to publicly post the URL as it's a testbed but if you're for some reason really interested feel free to send me a message at bill at my username here .com.

    Bill

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Try display:none.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •