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

Ajax Programming

Detecting NodeList object vs Array


I have a function were the input parameter can either be an
string,array,dom node or NodeList (getElementsByTagName()) and I have
somthing like this function which works great for what I want in every
case except if the pNd is the NodeList at which point I end up with the
nodeList in the first element of the array instead of acting like the
array would.

function doSomething(pNd){
        if(pNd.constructor != Array){pNd = new Array(pNd)}
        return pNd

}

So my question is how is there any easy way to figure out if pNd is a
NodeList ? When I use pNd.constructor on NodeList all I get is [object]

Thanks in advance.

Carl

Look into typeof
It will tell you what you are working with.
Eric

On 1/22/07, carlback <carlb@gmail.com> wrote:

On Jan 23, 2:47 am, "carlback" <carlb@gmail.com> wrote:

> So my question is how is there any easy way to figure out if pNd is a
> NodeList ? When I use pNd.constructor on NodeList all I get is [object]

Only can suggest to check whether the pNp supports NodeList methods,
like
if (pNp.item) {
  ...

}

Sincerely,
Alexander
http://www.alexatnet.com/ - PHP/Ajax tips, notes, tutorials
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc