Innerhtml and a tbody

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Gillen

    #1

    Innerhtml and a tbody

    Hello,

    I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
    okay.

    I have within my html
    <tbody id="dataTable" name="dataTable "></tbody>

    And then some javascript (using prototype to get the element)

    $('dataTable'). innerHTML = rows;

    FF displays the rows correctly.
    IE6 and 7 throw and error on the js line above.

    If I try and set the innerHTML of a div though in IE6 or 7 it works correctly,
    so I'm guessing they just don't support setting the innerHTML of a tbody.

    What might the alternatives be, it is tabular data so it kinda needs to go
    into a table.

    Thanks,
    David.
    --
    #define whilst while
    #define perchance if
    #define respond return
    whilst(someTest ){perchance(som eOtherTest){res pond var;}}
  • Joost Diepenmaat

    #2
    Re: Innerhtml and a tbody

    David Gillen <belial@RedBric k.DCU.IEwrites:
    Hello,
    >
    I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
    okay.
    >
    I have within my html
    <tbody id="dataTable" name="dataTable "></tbody>
    >
    And then some javascript (using prototype to get the element)
    >
    $('dataTable'). innerHTML = rows;
    >
    FF displays the rows correctly.
    IE6 and 7 throw and error on the js line above.
    >
    If I try and set the innerHTML of a div though in IE6 or 7 it works correctly,
    so I'm guessing they just don't support setting the innerHTML of a tbody.
    >
    What might the alternatives be, it is tabular data so it kinda needs to go
    into a table.
    IIRC you can create the whole table at once instead of just the
    tbody. IE has some issues with table creation. For instance, you can't
    use createElement() and appendChild to insert table cells. If you really
    want to do this portably you must use insertRow() and insertCell()
    instead.

    http://msdn2.microsoft.com/en-us/lib...98(VS.85).aspx

    Joost.

    Comment

    • Henry

      #3
      Re: Innerhtml and a tbody

      On Feb 7, 12:47 pm, Joost Diepenmaat wrote:
      <snip>
      ... . IE has some issues with table creation. For instance, you can't
      use createElement() and appendChild to insert table cells.
      <snip>

      You most certainly can use - createElement - and - appendChild - to
      insert table cells in every IE version since 5.

      Comment

      • Randy Webb

        #4
        Re: Innerhtml and a tbody

        David Gillen said the following on 2/7/2008 7:17 AM:
        Hello,
        >
        I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
        okay.
        You can't create parts of a table with innerHTML in IE. It just doesn't
        work right. You have to use what is referred to as the TOM (Table Object
        Model) to make it work right and reliably. You can't add a TR to a TABLE
        element in IE either, it makes you append it to a TBODY, but FF lets
        you append it straight to the table element.

        --
        Randy
        Chance Favors The Prepared Mind
        comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
        Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

        Comment

        • Joost Diepenmaat

          #5
          Re: Innerhtml and a tbody

          Henry <rcornford@rain drop.co.ukwrite s:
          On Feb 7, 12:47 pm, Joost Diepenmaat wrote:
          <snip>
          >... . IE has some issues with table creation. For instance, you can't
          >use createElement() and appendChild to insert table cells.
          <snip>
          >
          You most certainly can use - createElement - and - appendChild - to
          insert table cells in every IE version since 5.
          I'm sure I ran across issues doing that fairly recently, and I pretend
          IE < 6 doesn't exist.

          It may have been just me forgetting to insert a tbody, though. The last
          time I really checked it was ages ago.

          Oh well.

          Joost.

          Comment

          • Henry

            #6
            Re: Innerhtml and a tbody

            On Feb 7, 7:14 pm, Joost Diepenmaat wrote:
            Henry writes:
            >On Feb 7, 12:47 pm, Joost Diepenmaat wrote:
            ><snip>
            >>... . IE has some issues with table creation. For instance, you
            >>can't use createElement() and appendChild to insert table cells.
            ><snip>
            >
            >You most certainly can use - createElement - and - appendChild - to
            >insert table cells in every IE version since 5.
            >
            I'm sure I ran across issues doing that fairly recently, and I
            pretend IE < 6 doesn't exist.
            But that does not mean that bugs and mistakes in the code you write
            should be generalised into false statements made to individuals who
            may not know any better.
            It may have been just me forgetting to insert a tbody, though.
            You were attempting to append cells to a TBODY? That was never likely
            to have a predictable outcome.
            The last time I really checked it was ages ago.

            Comment

            • webbugtrack@gmail.com

              #7
              Re: Innerhtml and a tbody

              On Feb 7, 7:17 am, David Gillen <bel...@RedBric k.DCU.IEwrote:
              Hello,
              >
              I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
              okay.
              >
              I have within my html
              <tbody id="dataTable" name="dataTable "></tbody>
              >
              And then some javascript (using prototype to get the element)
              >
              $('dataTable'). innerHTML= rows;
              >
              FF displays the rows correctly.
              IE6 and 7 throw and error on the js line above.
              >
              If I try and set theinnerHTMLof a div though in IE6 or 7 it works correctly,
              so I'm guessing they just don't support setting theinnerHTMLof a tbody.
              Correct! IE doesn't support .innerHTML on a lot of elements, in
              particular with Tables, it doesn't work on TBody, THead or TFoot.

              See the bug report here:
              Issue: #210 Affects: IE6, IE7, IE8, IE9 RC 1 MSIE Feedback ID: 336254 | MSIE Feedback ID: 332545 Status: Microsoft has confirmed this wi...


              It also doesn't work on Select lists (see here):
              Issue: #124 Affects: IE6, IE7, IE8 Beta 1, IE8 Beta 2, IE8 PR1 Setting the .innerHTML in IE can fail in the following scenario. If you add...


              Comment

              Working...