innerHTML in IE vs Firefox

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

    #1

    innerHTML in IE vs Firefox



    Here is my problem in a nutshell: a script to model dynamic table
    extension. It works under Firefox. But IE just aborts, complaining about
    an "unknown runtime error" in the line with "innerHTML" . Why?

    <html><head></head><body>

    <script language="javas cript">
    function extend() {
    var tb = document.getEle mentById('theta ble').tBodies[0];
    var newrow = document.create Element('tr');
    tb.insertBefore (newrow,tb.rows[tb.rows.length-1]);
    tb.rows[tb.rows.length-2].innerHTML =
    '<td>A</td><td>dummy</td><td>row</td>';
    }
    </script>

    <table id="thetable">
    <tr><td>1-1</td><td>1-2</td><td>1-3</td></tr>
    <tr><td>2-1</td><td>2-2</td><td>2-3</td></tr>
    <tr><td>3-1</td><td>3-2</td><td>3-3</td></tr>
    <tr><td colspan="3"><a href="javascrip t:extend();">ex tend</a></td></tr>
    </table>
    </body>
    </html>



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Michael Winter

    #2
    Re: innerHTML in IE vs Firefox

    On 18 Dec 2004 13:20:35 -0600, gaehn gaehn <nospam@blackho le.org> wrote:
    [color=blue]
    > But IE just aborts, complaining about an "unknown runtime error" in the
    > line with "innerHTML" . Why?[/color]

    IE doesn't allow assignment to the innerHTML property of a table row. In
    fact, the only table-related elements that can be modified this way are
    CAPTION, TD and TH.
    [color=blue]
    > <html><head></head>[/color]

    HTML documents require a TITLE element.
    [color=blue]
    > <body>
    >
    > <script language="javas cript">[/color]

    The language attribute has been deprecated for over six years. Use the
    type attribute:

    <script type="text/javascript">

    [snip]
    [color=blue]
    > <a href="javascrip t:extend();">ex tend</a>[/color]

    See <URL:http://jibbering.com/faq/#FAQ4_24>.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    Working...