Connecting Tech Pros Worldwide Help | Site Map

Is "children" a valid property in Firefox?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:33 PM
Todd Cary
Guest
 
Posts: n/a
Default Is "children" a valid property in Firefox?

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

  #2  
Old July 23rd, 2005, 05:33 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: Is "children" a valid property in Firefox?



Todd Cary wrote:
[color=blue]
> 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?[/color]

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/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.