Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > document.createElement in IE with TR tag

Reply
Thread Tools

document.createElement in IE with TR tag

 
 
rain_c1@web.de
Guest
Posts: n/a
 
      10-18-2005
Hi!

I have problems with document.createElement() in IE when using TR tags.
Please look at the following very short example:

------------snip-----------------
<table id="test"></table>

<script type="text/javascript">
var MyTable = document.getElementById("test");
var myTR = document.createElement('tr');
var myTD = document.createElement('td');
var myText = document.createTextNode("this is text");

myTD.appendChild(myText);
myTR.appendChild(myTD);
MyTable.appendChild(myTR);
</script>
------------snip-----------------

this works fine in Firefox, but IE is very strange. It refuses to
display the created elements. Through further tests I realized, that
only the TR tag is the problem. If this is already in the static HTML
code it works in IE, too.

Further very strange: If I use the developer toolbar for IE and use the
DOM Explorer, it shows me, that all my dynamic generated tags are
there, but they are not displayed.

Has anybody an idea?

Thank you very much!

Best regards,
- Rainer

 
Reply With Quote
 
 
 
 
Matt Kruse
Guest
Posts: n/a
 
      10-18-2005
wrote:
> var MyTable = document.getElementById("test");


Get a reference to the tbody element instead of the table element.
When you don't explicitly put one in, IE puts one in for you.
A TR can only be appended to a tbody.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


 
Reply With Quote
 
 
 
 
rain_c1@web.de
Guest
Posts: n/a
 
      10-18-2005
this works very fine, thanks a lot!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
To vlan tag or not to tag? budyerr Cisco 1 07-08-2004 03:45 AM
using param or out tag inside sql tag (jsp/jstl/tomcat) shahbaz Java 0 10-27-2003 02:46 AM
struts tag inside a tag kishan bisht Java 1 07-08-2003 11:04 PM
How to embed the <jsp:plugin> tag into a tag handler class...HELP !! jstack Java 1 07-04-2003 06:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57