Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Is "children" a valid property in Firefox?

Reply
Thread Tools

Is "children" a valid property in Firefox?

 
 
Todd Cary
Guest
Posts: n/a
 
      02-03-2005
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
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-03-2005


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/
 
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
Binding to property of property of object collection TS ASP .Net 3 08-31-2006 12:57 PM
TableCell: BackColor Property But No BackGround Property? Nathan Sokalski ASP .Net 1 04-29-2006 10:09 PM
DataBinder.Eval for an object's property property... like Eval(Container.DataItem,"Version.Major") Eric Newton ASP .Net 3 04-04-2005 10:11 PM
Set CSS property equal to another CSS property? Noozer HTML 10 10-13-2004 09:20 PM
Is there a way to set the a CSS property to be explicitly the same as another CSS property? Joshua Beall HTML 1 12-10-2003 07:21 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