Chapter 3 DynaScript Predefined Objects


DOMAttribute properties

The DOMAttribute object has these properties as well as all the properties of the DOMNode object, which are inherited:

name property

Syntax

DOMAttribute.name

Description

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.

Example

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 );
}

See also

"getAttributeNode method".

specified property

Syntax

DOMAttribute.specified 

Attributes

This property is read-only.

Description

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.

Example

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 );
}
}

value property

Syntax

DOMAttribute.value

Attributes

This property is read/write.

Description

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.

Example

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.