children, childNodes problem in netscape

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deepthisoft
    New Member
    • Jul 2007
    • 27

    children, childNodes problem in netscape

    hi,
    Children element in javascript is not working in netscape. But is working fine in IE. ChildNodes element is also not working in Netscape. But it is working fine in
    IE.

    My code is look like this,
    [code=javascript]
    function fSetSelectedDay (my)
    {
    alert(parseInt( (my).childNodes ("dateText").in nerHTML));
    alert((myElemen t.children["calDateTex t"].innerText));
    //these two codings are working fine in the IE but not in Netscape
    }
    [/code]

    Anyone help me for this.
    This is vary helpful for me.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    innerText is not supported by most browsers. Have you tested in Mozilla/Firefox? What about others such as Opera, Safari, etc.?

    Show how this code is called and what "my" is.

    Comment

    • deepthisoft
      New Member
      • Jul 2007
      • 27

      #3
      This is my code
      [code=javascript]
      <html>
      <body>
      <script language=javasc ript>
      function fSetSelectedDay (my)
      {
      alert((my).chil dNodes("calDate Text").innerHTM L);
      alert(my.childr en["calDateTex t"].innerHTML);//It returns the value 5
      }

      </script>
      <table>
      <tr>
      <td valign='top' id=calCell onclick=fSetSel ectedDay(this)>

      <font id=calDateText >5</font>
      </td>
      <tr>
      </table>
      </body>
      </html>
      [/code]
      This code is working fine in IE and Opera but not in Netscape and Firefox.

      Thanks in advance.

      Comment

      • mrhoo
        Contributor
        • Jun 2006
        • 428

        #4
        Please excuse this post-

        Comment

        • rohitchawla
          New Member
          • Jul 2007
          • 85

          #5
          the way you are calling the childnodes is not correct but it still works in IE

          try these out

          [CODE=javascript]
          function fSetSelectedDay (my)
          {
          for(i=0;i<my.ch ildNodes.length ;i++)
          {
          if(my.childNode s[i].id=='calDateTe xt')
          {
          alert(my.childN odes[i].innerHTML);
          break;
          }
          }
          }
          [/CODE]
          or this one if u dont know id
          [CODE=javascript]
          function fSetSelectedDay (my)
          {
          for(i=0;i<my.ch ildNodes.length ;i++)
          {
          if(my.childNode s[i].nodeName=='FON T')
          {
          alert(my.childN odes[i].innerHTML);
          break;
          }
          }
          }
          [/CODE]

          Comment

          Working...