Click to return to the DHTML, HTML     
endElement Method     getComponentVersion Metho...     Default Behaviors Referen...    
Web Workshop  |  DHTML, HTML & CSS

getAttribute Method


Retrieves the value of the specified attribute.

Syntax

vAttribute = oPersistObject.getAttribute(sAttrName)

Parameters

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

Return Value

Variant. Returns a string, number, or 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.

Remarks

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 desired 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.

Example

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

Sample Code

<HEAD>

<STYLE>
   .userData {behavior:url(#default#userdata);}
</STYLE>   

<SCRIPT>
   function fnGet(){
      oPersistInput.load("oDataStore");
      oPersistInput.value=oPersistInput.getAttribute("sPersistAttr");
   }
   function fnSet(){
      oPersistInput.setAttribute("sPersistAttr",oPersistInput.value);
      oPersistInput.save("oDataStore");
   }
   function fnRem(){
      oPersistInput.removeAttribute("sPersistAttr");
      oPersistInput.save("oDataStore");
   }
</SCRIPT>
</HEAD>

<BODY >
<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()">
</BODY>
This feature requires Internet Explorer 5 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
saveFavorite, saveHistory, userData

See Also

DHTML Behaviors, Persistence Overview, removeAttribute, setAttribute


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.