Skip to content
May 20, 2009 / kiranpatils

Insert Cell alternative for Firefox

Hi folks Sorry for being invisible since so long. But i really got tied up with my bits. 🙂

Anyway today i have something to share with you all so here it is:


I have one JavaScript in which i am creating one table cell and adding it to table. It works fine in IE[As always :)] But not in FF[As always :)].

var newTable = document.createElement(‘table’);
var newRow = newTable.insertRow( ); 
 var newCell1 = newRow.insertCell( );


So, finally my friend Google helped me to find a way:

just pass –1 to insertCell Method and have a good sleep!

var newTable = document.createElement(‘table’);
var newRow = newTable.insertRow( ); 
var newCell1 = newRow.insertCell( -1);


I don’t know. If you do please do let me know 🙂

Happy Programming!




Leave a Comment
  1. LakOr / Jul 5 2009 5:30 pm

    thanks for this solution…
    I lost like 2 hours to get this…

    U are the men… 😀

    Cya later

  2. RSREDDY / Aug 20 2009 10:27 am

    In any case, to add a cell to the end of oRow1, do it directly:

    newRow.insertCell( -1);

    Incidentally, IE will allow you to use no index for the inserted row, that will cause an error in other browsers. The index parameter is required by the specification.

    Always try yo follow the W3C specification for JavaScript.
    That would be working in all browsers 😉

  3. coreyman / Oct 15 2009 6:37 pm

    Thank you very much for posting this, I spent a few hours trying to figure this out, and eventually gave up. I went searching again and your solution was accurate! Thank you.

  4. rakesh / Aug 24 2011 1:02 pm

    rakesh mangtani>> it was really cool fix, btw firefox requires index to be provided for insertcell function.


  1. Chrome Download Button

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: