Re: How do I get the object type from document.all?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: How do I get the object type from document.all?

From: Michael Winter <m.winter@blueyonder.co.uk>
Date: Sun Aug 14 2005 - 16:24:27 CEST

On 14/08/2005 13:06, seans wrote:

[snip]

> if (document.all['elementID'].len­gth) { // we have an array
>
> }
> else { // we have a single object
>
> }

Except where the element has its own length property, as in the FORM and
SELECT elements. Perhaps a better test is to check for the tags method,
which should only exist on all-based collections.

Still, the all collection should, in my opinion, only be used in two
circumstances:

   1) When writing code for IE 4.
   2) When fixing-up the getElementsByTagName method in IE 5.x and
      earlier, when its argument is an asterisk ('*').

In other circumstances, it should be abandoned in favour of the
getElementById method.

Mike

-- 
Michael Winter
Prefix subject with [News] before replying by e-mail.
Received on Tue Oct 18 03:08:54 2005