Skip to main content
getAttribute Method

This topic documents a feature of Binary Behaviors, which are obsolete as of Internet Explorer 10.

Retrieves the value of the specified attribute.


vAttribute = object.getAttribute(sAttrName)


sAttrName Required. A String that specifies the name of the persistent attribute.

Return Value

Variant. Returns a string, a number, or a Boolean, defined by sAttrName. If an explicit attribute doesn't exist, an empty string is returned. If a custom attribute doesn't exist, null is returned.


The sAttrName value is not case-sensitive.

This method requires an object participating in persistence, where that object has a class name equal to the specified persistence behavior. An ID is required for the userData and saveSnapshot behaviors, and is recommended for the saveHistory and saveFavorite behaviors.

This method overrides the DHTML getAttribute method.


This example uses the getAttribute method to retrieve an attribute on an object participating in userData persistence.


   .userData {behavior:url(#default#userdata);}

   function fnGet(){
   function fnSet(){
   function fnRem(){

<INPUT type=text class=userData id=oPersistInput> 
<INPUT type=button value="Get Attribute" onclick="fnGet()">
<INPUT type=button value="Set Attribute" onclick="fnSet()">
<INPUT type=button value="Remove Attribute" onclick="fnRem()">

Code example:

Applies To

saveFavorite, saveHistory, userData

See Also