wrote:
> On Dec 15, 7:12 pm, David Mark <dmark.cins...@gmail.com> wrote:
>> On Dec 15, 4:41 pm, mk83...@yahoo.com wrote:
>>> for (var i=0; i<lnks.length; i++) {
>>> if (lnks[i].getAttribute("class") == "popup") {
>> Oops. MS botched getAttribute. Won't work for "class." Use the
>> className property instead.
>
> What?, getAttribute("class") changes between browsers. That's a basic
> commonly used function.
No, it is not, at least not among developers with a minimum clue.
First, it is a _method_. As it is a host object's method it is not
necessarily available as a native Function object.
Second, HTML element objects have attribute-value properties that should be
used where possible instead of calling getAttribute(). In this case, the
`className' attribute of the HTMLElement interface, and so the `className'
property of the object referred to by `lnks[i]' provides access to the
represented element's `class' attribute value. (`class' as interface
attribute/object property name was not available as `class' is a reserved
word in the languages for which binding is defined.)
Third, getAttribute() returns the *attribute* value. That is not (always)
identical with the current value of the *element object*, as it is the case
for form controls.
http://www.w3.org/TR/DOM-Level-2-HTML/
(Proprietary DOMs implement these interfaces or define attribute-value
properties themselves.)
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>