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.onclic k=HideMenuBar;
var bar = menuBar.childre n; <-------------<<<
alert("Got to here " + bar.length.toSt ring());
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/