Is "children" a valid property in Firefox?

Discussion in 'Javascript' started by Todd Cary, Feb 3, 2005.

  1. Todd Cary

    Todd Cary Guest

    In my previous post, I stated that some JavaScript I inherited does not
    work in Firefox but does work in IE 6 [in my first post I mixed up the
    browsers]. I have now isolated a line where it fails in Firefox; the
    line with the property of "children".

    function InitMenu()
    {
    if (document.all["menuBar"])
    {
    }
    else
    {
    return;
    }
    document.onclick=HideMenuBar;
    var bar = menuBar.children; <-------------<<<
    alert("Got to here " + bar.length.toString());

    Has anyone else had this problem? Work around?

    Many thanks....

    Todd
     
    Todd Cary, Feb 3, 2005
    #1
    1. Advertising

  2. Todd Cary wrote:

    > In my previous post, I stated that some JavaScript I inherited does not
    > work in Firefox but does work in IE 6 [in my first post I mixed up the
    > browsers]. I have now isolated a line where it fails in Firefox; the
    > line with the property of "children".
    >
    > function InitMenu()
    > {
    > if (document.all["menuBar"])
    > {
    > }
    > else
    > {
    > return;
    > }
    > document.onclick=HideMenuBar;
    > var bar = menuBar.children; <-------------<<<
    > alert("Got to here " + bar.length.toString());
    >
    > Has anyone else had this problem? Work around?


    Mozilla implements the W3C DOM, it is documented here for the Core:
    <http://www.w3.org/TR/DOM-Level-2-Core/>
    and for the HTML stuff here:
    <http://www.w3.org/TR/DOM-Level-2-HTML/>
    Look there if you want to find properties or methods.

    As for children, no, in its DOM nodes do not have a property children,
    there is a property childNodes however which is similar but not quite
    the same (children only covers element nodes but childNodes text nodes
    as well).
    But IE 5 and later implement much of the W3C DOM too so using childNodes
    for instance with Mozilla and IE (5 and later) is possible.
    I would strongly suggest if you are writing script nowadays then you try
    to use the W3C DOM first as then you can easily cover IE 5/6, Mozilla
    1.x and later, Netscape 6/7, Firefox, Opera 7, Konqueror, Safari.
    If you stick with stuff coming from the IE 4 DOM (like document.all or
    children) then you will find different support in non IE browsers,
    sometimes depending on the version or even the rendering mode. For
    instance Mozilla versions before Mozilla 1.7.5 or Firefox 1.0 don't
    support document.all while by now (only in quirks mode) undetected
    document.all support is added. But that only means that someone using
    document.all now with Firefox finds an element but then further IE
    specific stuff like children on that element fail.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Feb 3, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Heavey
    Replies:
    0
    Views:
    1,240
    Jim Heavey
    Apr 14, 2004
  2. Lisa Calla
    Replies:
    1
    Views:
    3,542
    Kumar Reddi
    Nov 8, 2004
  3. Adam Tibi

    Intellisense for the children of a Complex Property

    Adam Tibi, Jan 20, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    97
    Adam Tibi
    Jan 20, 2006
  4. Angel
    Replies:
    10
    Views:
    174
    Robert
    Jun 20, 2006
  5. Thierry Lam
    Replies:
    7
    Views:
    152
Loading...

Share This Page