IE SP2 solution for "null is null or not an object" and "broken" insertCell/insertRow

Discussion in 'Javascript' started by putty, Apr 5, 2005.

  1. putty

    putty Guest

    I found a few posts of people asking about insertCell()/insertRow() not
    working in IE6 SP2, and a few others about getting "null is null or not
    an object" errors, but no one posted a solution anywhere or noted this
    tiny yet curious change in SP2.. so here it is:

    In IE6 SP2 rows must be inserted into a tBody instead of a Table
    directly, after that you may insert TDs into TRs any way you wish.
    insertRow() and insertCell() work the same as always; the underlying
    problem simply emanated from the fact that people were adding TRs to
    Tables instead of their tBodies. I guess IE6 SP2 is less forgiving than
    SP1?

    The following will not work in IE6 SP2 but will work in Firefox and IE6
    SP1:
    -- code --
    var Table = document.createElement( "Table" );

    var Row = Table.insertRow(-1);
    var Cell1 = Row.insertCell(-1);
    var Cell2 = Row.insertCell(-1);
    -- code --

    The following will work in Firefox, IE6 SP1, and IE6 SP2:
    -- code --
    var Table = document.createElement( "Table" );
    var tBody = document.createElement( "tBody" );
    Table.appendChild( tBody );

    var Row = tBody.insertRow(-1);
    var Cell1 = Row.insertCell(-1);
    var Cell2 = Row.insertCell(-1);
    -- code --

    The error several IE6 SP2 clients saw when running the non-working code
    was "null is null or not an object."

    Hope this helps someone.
    -- putty
    putty, Apr 5, 2005
    #1
    1. Advertising

  2. putty

    putty Guest

    This is specifically a problem when building tables manually.. where
    tBodies might not be automatically created for you upon doing
    insertRow() on a Table object.

    I don't have SP2 here so I could not double check the "non-working"
    code sample -- I'm beginning to think that it might work in SP2 given
    no tBodies deletion was conducted before running insertRow().
    putty, Apr 5, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George
    Replies:
    5
    Views:
    751
    =?Utf-8?B?S2VuIEJlYXJk?=
    Aug 24, 2004
  2. Likhith Areekkal

    Calendars overlap : IE SP2 ; WinXP SP2

    Likhith Areekkal, Dec 23, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    122
    Likhith Areekkal
    Dec 23, 2004
  3. will

    insertCell problems

    will, Aug 14, 2003, in forum: Javascript
    Replies:
    4
    Views:
    127
  4. Howard Jess

    Internet Explorer insertRow/insertCell failure

    Howard Jess, Nov 4, 2005, in forum: Javascript
    Replies:
    2
    Views:
    308
    GĂ©rard Talbot
    Nov 5, 2005
  5. Replies:
    1
    Views:
    94
Loading...

Share This Page