Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

getting the id of a given child, doesnt work in ff but does in safari


in firefox the following alert does not get created from my function:

ch = container1.childNodes(0).id;
alert(ch)

can anyone tell why this might not work in firefox but does in safari?

thanks

marc

libsfan01 wrote:
> in firefox the following alert does not get created from my function:

> ch = container1.childNodes(0).id;

childNodes is a list, not a function - some browsers are confused about
that:

   var ch = container1.childNodes[0].id;

--
Rob
  "We shall not cease from exploration, and the end of all our
   exploring will be to arrive where we started and know the
   place for the first time." -- T. S. Eliot

On May 15, 11:31 am, libsfan01 <mcyi2@googlemail.com> wrote:

> in firefox the following alert does not get created from my function:

> ch = container1.childNodes(0).id;
> alert(ch)

> can anyone tell why this might not work in firefox but does in safari?

Are you getting an error in the console?

---
Geoff

Geoffrey Summerhayes a crit :

> On May 15, 11:31 am, libsfan01 <mcyi2@googlemail.com> wrote:
>> in firefox the following alert does not get created from my function:

>> ch = container1.childNodes(0).id;
>> alert(ch)

>> can anyone tell why this might not work in firefox but does in safari?

Why it could work in Safary I don't know,
but why it doesn't work in FF :
because the first chidNode in FF is an invisible text node (without id)
and anyway ... it is :

    ch = container1.childNodes[0];

> Are you getting an error in the console?

He can also have a look in Firefox's DOM inspector ( #text )

test :
======
   ch = container1.childNodes[0];
   alert(ch.nodeName);

--
Stephane Moriaux et son (moins) vieux Mac dj dpass
Stephane Moriaux and his (less) old Mac already out of date

On May 15, 12:45 pm, ASM <stephanemoriaux.NoAd@wanadoo.fr.invalid>
wrote:

Actually the absence of id wouldn't cause a problem for this,
FF would show 'undefined' in the alert box. Round brackets
as opposed to square definitely are the culprit.

> > Are you getting an error in the console?

> He can also have a look in Firefox's DOM inspector ( #text )

Depends a lot on what container1 is, a text node isn't always
the first child.

But it's always a good idea to learn to use the tools that are
there to make the job easier.

---
Geoff

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc