473,479 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Innerhtml and a tbody

Hello,

I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
okay.

I have within my html
<tbody id="dataTable" name="dataTable"></tbody>

And then some javascript (using prototype to get the element)

$('dataTable').innerHTML = rows;

FF displays the rows correctly.
IE6 and 7 throw and error on the js line above.

If I try and set the innerHTML of a div though in IE6 or 7 it works correctly,
so I'm guessing they just don't support setting the innerHTML of a tbody.

What might the alternatives be, it is tabular data so it kinda needs to go
into a table.

Thanks,
David.
--
#define whilst while
#define perchance if
#define respond return
whilst(someTest){perchance(someOtherTest){respond var;}}
Feb 7 '08 #1
6 10737
David Gillen <be****@RedBrick.DCU.IEwrites:
Hello,

I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
okay.

I have within my html
<tbody id="dataTable" name="dataTable"></tbody>

And then some javascript (using prototype to get the element)

$('dataTable').innerHTML = rows;

FF displays the rows correctly.
IE6 and 7 throw and error on the js line above.

If I try and set the innerHTML of a div though in IE6 or 7 it works correctly,
so I'm guessing they just don't support setting the innerHTML of a tbody.

What might the alternatives be, it is tabular data so it kinda needs to go
into a table.
IIRC you can create the whole table at once instead of just the
tbody. IE has some issues with table creation. For instance, you can't
use createElement() and appendChild to insert table cells. If you really
want to do this portably you must use insertRow() and insertCell()
instead.

http://msdn2.microsoft.com/en-us/lib...98(VS.85).aspx

Joost.
Feb 7 '08 #2
On Feb 7, 12:47*pm, Joost Diepenmaat wrote:
<snip>
... . IE has some issues with table creation. For instance, you can't
use createElement() and appendChild to insert table cells.
<snip>

You most certainly can use - createElement - and - appendChild - to
insert table cells in every IE version since 5.

Feb 7 '08 #3
David Gillen said the following on 2/7/2008 7:17 AM:
Hello,

I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
okay.
You can't create parts of a table with innerHTML in IE. It just doesn't
work right. You have to use what is referred to as the TOM (Table Object
Model) to make it work right and reliably. You can't add a TR to a TABLE
element in IE either, it makes you append it to a TBODY, but FF lets
you append it straight to the table element.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 7 '08 #4
Henry <rc*******@raindrop.co.ukwrites:
On Feb 7, 12:47Â*pm, Joost Diepenmaat wrote:
<snip>
>... . IE has some issues with table creation. For instance, you can't
use createElement() and appendChild to insert table cells.
<snip>

You most certainly can use - createElement - and - appendChild - to
insert table cells in every IE version since 5.
I'm sure I ran across issues doing that fairly recently, and I pretend
IE < 6 doesn't exist.

It may have been just me forgetting to insert a tbody, though. The last
time I really checked it was ages ago.

Oh well.

Joost.
Feb 7 '08 #5
On Feb 7, 7:14 pm, Joost Diepenmaat wrote:
Henry writes:
>On Feb 7, 12:47 pm, Joost Diepenmaat wrote:
<snip>
>>... . IE has some issues with table creation. For instance, you
can't use createElement() and appendChild to insert table cells.
<snip>
>You most certainly can use - createElement - and - appendChild - to
insert table cells in every IE version since 5.

I'm sure I ran across issues doing that fairly recently, and I
pretend IE < 6 doesn't exist.
But that does not mean that bugs and mistakes in the code you write
should be generalised into false statements made to individuals who
may not know any better.
It may have been just me forgetting to insert a tbody, though.
You were attempting to append cells to a TBODY? That was never likely
to have a predictable outcome.
The last time I really checked it was ages ago.
Feb 8 '08 #6
On Feb 7, 7:17 am, David Gillen <bel...@RedBrick.DCU.IEwrote:
Hello,

I'm hoping someone can shed some light on this, problem is in IE6 and 7. FF is
okay.

I have within my html
<tbody id="dataTable" name="dataTable"></tbody>

And then some javascript (using prototype to get the element)

$('dataTable').innerHTML= rows;

FF displays the rows correctly.
IE6 and 7 throw and error on the js line above.

If I try and set theinnerHTMLof a div though in IE6 or 7 it works correctly,
so I'm guessing they just don't support setting theinnerHTMLof a tbody.
Correct! IE doesn't support .innerHTML on a lot of elements, in
particular with Tables, it doesn't work on TBody, THead or TFoot.

See the bug report here:
http://webbugtrack.blogspot.com/2007...on-tables.html

It also doesn't work on Select lists (see here):
http://webbugtrack.blogspot.com/2007...oblem-no1.html

Feb 8 '08 #7

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

Similar topics

11
2477
by: kaeli | last post by:
Hey all, AFAIR, innerHTML started as MS proprietary, but Mozilla implemented it as well. Does anyone know if any other browsers support it? It is not in the W3C DOM, is it? A quick GIS seemed to...
22
2811
by: necromonger | last post by:
Hi, I've got this code that creates a new new row and cell. I then put some text into the cell with innerHTML - works beautifully with Firefox but fails with IE. I guess IE doesn't support this...
4
2225
by: mlybarger | last post by:
IE seems to munge the innerHTML of a document, does anyone know why it's changing the innerHTML? <body> <div style="background-color:LightGrey;" onclick="window.alert( 'one:' +...
4
6531
by: RobG | last post by:
I know you aren't supposed to use innerHTML to mess with table structure, but it seems you can't use it just after a table without damaging the containing element. I added a table to a div using...
4
1745
by: bissatch | last post by:
Hi, I have the following simple HTML page. I am trying to get the innerHTML of the table element, "xmltable". I do intend to change the innerHTML of this table but at this stage I am having...
5
6337
by: r_ahimsa_m | last post by:
Hello, I am lerning HTML/CSS/JavaScript. I created HTML page with table "property_fields" containing 24 rows ('tr' elements). I want to remove last 23 rows: var table =...
4
2072
by: bgold12 | last post by:
I'm adding a <trelement dynamically to a web page. The relevant HTML starts off like the following: <table><tbody id="tbodyID"> <tr>...</tr> <tr>...</tr> </tbody></table> After the page has...
6
4196
by: PaPa | last post by:
I'm not sure this is a javascript issue or an HTML issue. I notice that when I extract the contents of a div using the innerHTML property (?), that I wind up with a literal variable (?) which...
1
3162
Claus Mygind
by: Claus Mygind | last post by:
In the code below I want to include the values of an array that only exist in the function where this code is located. But I get the following error: As shown in the code below I try to add the...
0
7033
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
7027
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,...
1
6726
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
6861
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...
1
4763
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...
0
2987
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...
0
1291
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 ...
1
557
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
170
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...

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.