Chapter 3 DynaScript Predefined Objects
The DOMAttribute
object
has these properties as well as all the properties of the DOMNode
object,
which are inherited:
DOMAttribute.name
Returns the name of the attribute.
For the following start tag of an element:
<Region Type="State">
there is one attribute, which has the name Type.
The following DynaScript fragment writes out
the name of each attribute of a DOMElement
object
named elem:
attlist = elem.attributes
for( iAtt=0; iAtt < attlist.length; iAtt++ ) {
document.writeln( attlist.item(iAtt).name );
}
DOMAttribute.specified
This property is read-only.
If the attribute was explicitly given a value in the original document, the specified property will be set to true. If no value was given the specified property is set to false.
This property is set to true if the value of the attribute is changed.
Attributes whose values are not explicitly specified, but are instead inferred from the DTD are not yet supported and do not appear within the document tree. Therefore, for attributes within the document tree, this property is always true.
This example writes out the name of each specified
attribute of a DOMElement
object
named elem:
attlist = elem.attributes
for( iAtt=0; iAtt < attlist.length; iAtt++ ) {
if( attlist.item(iAtt).specified == true ){
document.writeln( attlist.item(iAtt).name );
}
}
DOMAttribute.value
This property is read/write.
When retrieved, this property returns the attribute value as a string. Entity references will be replaced by their values.
When set, a DOMText
object
representing the string is created, and will become the only child
of the DOMAttribute
object.
For the following start tag of an element:
<Region Type="State">
there is one attribute, which has the value State.
This DynaScript fragment writes out the value
of each specified attribute of a DOMElement
object
named elem:
attlist = elem.attributes
for( iAtt=0; iAtt < attlist.length; iAtt++ ) {
document.writeln( attlist.item(iAtt).value );
}
}
Copyright © 1999 Sybase, Inc. All rights reserved. |