Exporter (0) Imprimer
Développer tout
EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

getAttributeNode method

Retrieves an attribute object referenced by the attribute.name property.

Document Object Model (DOM) Level 3 Core Specification, Section 1.4

Syntax

object.getAttributeNode(bstrname, ppAttribute)

Parameters

bstrname [in]
C++String that specifies the name property of the requested IHTMLDOMAttribute2 interface.
JavaScriptA String that specifies the name property of the requested attribute object.
ppAttribute [out, retval]
C++Address of a pointer variable that receives an IHTMLDOMAttribute2 pointer.
JavaScriptReturns a reference to an attribute object.

Return value

Type: IHTMLDOMAttribute

Returns a reference to an attribute object.Address of a pointer variable that receives an IHTMLDOMAttribute2 pointer.

Standards information

Remarks

Windows Internet Explorer 8 or later. In IE8 Standards mode, getAttributeNode correctly populates the value property of the returned attribute object regardless of whether the specified property is set to true or false. For more information on IE8 mode, see Defining Document Compatibility.

Internet Explorer 8 or later. In IE8 mode, the value property is correctly reported as a canonical attribute name. For example, <input type="text" readonly> and <input type="text" readonly="readonly"> would both set the input text field to read-only. In IE8 mode, the value is evaluated as a canonical value, "readonly". In IE7 and earlier modes, it is evaluated as a Boolean value, true.

getAttributeNode was introduced in Microsoft Internet Explorer 6.

Examples

The following example uses getAttributeNode to create an attribute object and populate its value property, which is then passed by reference to an output variable for assignment to the contents of a div element. Note how the call to setAttribute changes the href value for the content attribute but not for the DOM attribute.


<html>
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=8">
  <title>Attribute Node Example</title>
  <base href="http://msdn.microsoft.com/">
  <script>
    function GetAttrNode(){
     //Retrieve an attribute node and a DOM attribute.
     var o = document.getElementById("msdn");
     var sDomAttr = o.href;
     
     o.setAttribute('href', 'en-us/ie/default.aspx');
     var sContentAttr = o.getAttributeNode("href");
     var sOutput = ("Content attribute node value: " + sContentAttr.value + 
              "<br/>DOM attribute value: " + sDomAttr);
              
     document.getElementById("output").innerHTML = sOutput;
    }
  </script>
</head>
<body>
   <a id="msdn" href="en-us/default.aspx">Microsoft Developer Network</a>
   <div id="output" onmouseover="GetAttrNode()">Point here to display attribute values.</div>
</body>
</html>

See also

a
abbr
acronym
address
applet
area
b
base
baseFont
bdo
bgSound
big
blockQuote
body
br
button
caption
center
cite
code
col
colGroup
comment
custom
dd
del
dfn
dir
div
dl
dt
em
embed
fieldSet
font
form
frame
frameSet
head
hn
hr
html
i
iframe
img
input type=button
input type=checkbox
input type=email
input type=file
input type=hidden
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
ins
isIndex
kbd
label
legend
li
link
listing
map
marquee
menu
nextID
noBR
noFrames
noScript
object
ol
option
p
plainText
pre
q
rt
ruby
s
samp
script
select
small
span
strike
strong
style
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
title
tr
tt
u
ul
var
wbr
xml
xmp

 

 

Afficher:
© 2014 Microsoft