473,624 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><ti tle>Table API test</title>
<style type="text/css">
table{border:1p x dotted #999;margin:2px ;background-color:#ddd}
</style>
<script type="text/javascript">
function buildTable(divi d) {
var row,cell,tbody, table;

tbody = document.create Element('tbody' );
row = tbody.insertRow (0);
cell = row.insertCell( 0);
cell.appendChil d(document.crea teTextNode('tab lecell'));

table = document.create Element('table' );
table.appendChi ld(tbody);
document.getEle mentById(divid) .appendChild(ta ble);
return false;
}
</script>
</head><body>
<h1>Table API Test</h1>
<div id="tableDiv"> </div>
<form action="" onsubmit="retur n buildTable('tab leDiv')">
<p><input type="submit" value="Build Table"></p>
</form></body></html>
Nov 4 '05 #1
2 9521
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
17931
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 new row below the row the button is in. The new row also has these buttons, but when pressing one of these buttons, nothing happens. Can someone tell me why? here's the code to the addLevel button:
3
16192
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 addRowDOM (tableID) {
1
3170
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 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...
6
3309
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 is possible to Add and Delete rows - Some cells have special attributes (readonly and events) Here's a snippet of the code:
3
1805
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 displayed. Could someone explain to me how a dynamic table should be created (in IE)? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> ...
2
2590
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 just a blank page in IE 6. Can anybody tell me what I should change to make IE happy? Even better, is there any kind of tutorial out there on dynamically generating tables? Many thanks,
3
1675
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? Thanks. Kind regards. Luke Baker. my functions:
1
15779
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 createRows(deviceId,deviceType,modelName,ipAddress,macAddress,imageURL)
3
2919
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 mozilla perfectly but not in IE. To check where is the fault i have written so many alert() but sometimes these are working. Please someone read my code and tell me why its not working. i am also sending you the function validateIPandNetMask() my...
0
8236
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8173
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8679
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8621
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.