473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Internet Explorer insertRow/insertCell failure

CLJ --

I've searched the newsgroup and FAQ for info on insertRow(), but
didn't see this reported.

It seems that Internet Explorer doesn't respond correctly to either
insertRow() or insertCell(), if the object that calls this method isn't
already within a table. That is:

row = tbody.insertRow(0); // fails if tbody's parent is null
cell = row.insertCell(0); // fails if row's parent or grandparent is null

By "fail", I mean the method returns null. As I understand the DOM spec,
this behavior is wrong. Am I missing something? Mozilla, Opera, and
Safari work as expected.

Thanks for any help.

Howard Jess

Test file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Table API test</title>
<style type="text/css">
table{border:1px dotted #999;margin:2px;background-color:#ddd}
</style>
<script type="text/javascript">
function buildTable(divid) {
var row,cell,tbody,table;

tbody = document.createElement('tbody');
row = tbody.insertRow(0);
cell = row.insertCell(0);
cell.appendChild(document.createTextNode('tablecel l'));

table = document.createElement('table');
table.appendChild(tbody);
document.getElementById(divid).appendChild(table);
return false;
}
</script>
</head><body>
<h1>Table API Test</h1>
<div id="tableDiv"></div>
<form action="" onsubmit="return buildTable('tableDiv')">
<p><input type="submit" value="Build Table"></p>
</form></body></html>
Nov 4 '05 #1
2 9502
Howard Jess wrote:
CLJ --

I've searched the newsgroup and FAQ for info on insertRow(), but
didn't see this reported.

It seems that Internet Explorer doesn't respond correctly to either
insertRow() or insertCell(), if the object that calls this method isn't
already within a table. That is:

row = tbody.insertRow(0); // fails if tbody's parent is null
cell = row.insertCell(0); // fails if row's parent or grandparent is null

By "fail", I mean the method returns null. As I understand the DOM spec,
this behavior is wrong. Am I missing something? Mozilla, Opera, and
Safari work as expected.


Perhaps not strictly 'wrong', but certainly 'not as expected'. The logic
might be that a tbody must belong to a table, and a row to a tbody and a
table. But that seems like making excuses: when building elements
dynamically they must exist for some (short) time with invalid
structures - rows will not have cells when they are created, nor tbodys
rows, etc.
The Microsoft documentation says:

"If you insert a row in a tFoot, tBody, or tHead, you also need to
add the row to the rows collection for the table. If you insert a
row in the table, you also need to add the row to the rows collection
for the tBody."

<URL:http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/insertrow.asp>
Confusing (their code example is not worth quoting)?

Just another IE quirk?
[...]

--
Rob
Nov 5 '05 #2
Howard Jess a écrit :
CLJ --

I've searched the newsgroup and FAQ for info on insertRow(), but
didn't see this reported.

Search for "insertRow() in iteration loop does not work" at this IE 6
product feedback page:

http://channel9.msdn.com/wiki/defaul...rogrammingBugs

Gérard
--
remove blah to email me
Nov 5 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marco Alting | last post by:
Hi I'm currently developing a form with a dynamic table. initially the table is populated with data and at the end of each row there are two buttons: addLevel and addItem. Each button creates a...
3
by: milkyway | last post by:
Hello, I am working with an old Java Script code and have found the following but after putting in alerts I have found that insertRow doesn't work. What is the problem? TIA function...
1
by: putty | last post by:
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...
6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
3
by: Mahmoud | last post by:
When I wrote the following code to create a dynamic table with styles associated with each row, it worked in Firefox. But when this was tried in IE, the result was a table with no styles that were...
2
by: aric.bills | last post by:
Hello all, I'm a novice Javascript programmer, and I'm having browser compatability issues regarding dynamic generation of tables. The following content generates "hello" in Firefox 1.5, but...
3
by: edencane | last post by:
Hi. I've created a page that dynamically adds rows to a table. When I submit the page the request parameters of the dynamically generated rows don't get passed to the server. What is wrong?...
1
by: raju78.k | last post by:
Hi, I have a problem with FireFox. I have written a function to Add rows without submiting the form. This function works fine in IE, but not in FireFox. The function is : function...
3
by: BibhuAshish | last post by:
Hello guys i have one function which converts the ip/netmask into networkid/netmask and also it shows the message to user that his ip is changed to network id. but that function is working in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.