IE and Mozilla .. DOM parsing.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #1

    IE and Mozilla .. DOM parsing.

    Have a look at my HTML code...

    Code:
    <TD some..attributes ..... id="my_TD">
     <TABLE ... >
     .
     .
     </TABLE>
    </TD>
    Now see what i am getting in Mozilla 2.0 and IE 6.0
    Code:
    alert(document.getElementById('my_ID').childNodes.length);
    In Mozilla it shows 2 (it's ovious, first child is textNode and next child is "TABLE"), but in IE it shows 1 .. only the child "TABLE".
    How do i solve this?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I don't think, you can solve it, but does it really matter? (well, depending on what you do)

    btw. IE's DOM implementation is not the best…

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      Originally posted by Dormilich
      I don't think, you can solve it, but does it really matter? (well, depending on what you do)

      btw. IE's DOM implementation is not the best…
      hmmm :P
      Well so to access the "Table" what would be the generalized code? ;)

      Code:
      tabChild = parentNode.childNodes[0].tagName && parentNode.childNodes[0].tagName=='table'?parentNode.childNodes[0]:parentNode.childNodes[1];
      S***, IE is so hell :(
      Last edited by Dormilich; Apr 23 '09, 06:08 AM. Reason: swearing shortens your life ;)

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Code:
        document.getElementById("my_TD").getElementsByTagName("table")[0];

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          Originally posted by Dormilich
          Code:
          document.getElementById("my_TD").getElementsByTagName("table")[0];
          Yeah that's good, Actually i always have been using "document.getEl ementsByTagName ", but it can be with any element to find out the childNodes ;)
          2 3 days earlier i read the MDC document there i saw it, but could not apply it here.
          Thanks !

          Comment

          Working...