getAttributeNode (W3C DOM Core method)
var langnode = document.documentElement.getAttributeNode('lang');
The example above retrieves the
lang attribute node
attached to the the
saves it to the variable langnode.
On an HTML
documentElement is the root
html element, so if it looked like this:
Attr node with the specified name.
This method is for working with non-namespaced attribute nodes; to
get a namespaced attribute node, use the DOM 2
getAttributeNodeNS method instead.
The attribute node; or
null if the specified attribute is not defined.
Internet Explorer 5.5 in HTML doesn't implement this method (it returns undefined).
Firefox, Safari and
Opera 9.5 do not match attributes which are not
explicitly defined but have a specific default value in this document
type, such as the
shape attribute of an
a element (only Opera 9.0
gets this right).
Opera 9.0 returns an
interpreted value for the
value of a
style attribute node, rather than the literal
value. For example, this value in HTML:
color: #008000; font-size: 1.50em; left: 0.50ex;
You can see how several changes are evident — the color value has been
interpreted to hexadecimal, the font-size and left values have been
normalized with leading and trailing zeros, and the fake value (for which
read: value it doesn't understand) has been removed. A space has also been
inserted after each colon and semi-colon. This is identical to its
Firefox has similar, but less
aggressive, behavior — leading zeros are added to float values which begin
with a dot, non-understood values are removed, and a space is added after
each colon and semi-colon; but float values are not otherwise normalized
and colors are not interpreted. This is also identical to its behavior
Internet Explorer 6 and 7 in HTML
value of a static
href attribute from an
return a fully-qualified URI, rather than the literal value. (For a
link element they correctly returns the literal value.)
They also return a qualified URI for the
of a static
src attribute from an
img element. However their behavior is different when
retrieving values from a dynamically-created attribute node — see
setAttributeNode for details. They also return
null for a
There are no comments yet.