Magazine |
| | Community |
| | Workshop |
| | Tools & Samples |
| | Training |
| | Site Info |
|
|
||||||||
|
Retrieves the value of the specified attribute.
Syntax
vAttribute = oPersistObject.getAttribute(sAttrName)
Parameters
sAttrName Required. Name of the persistent attribute.
Return Value
Variant Returns a string, number or boolean defined by sAttrName.
Remarks
The persistent getAttribute method's attribute name 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 recommended for the saveHistory and saveFavorite behaviors.
The getAttribute method for behaviors will override the DHTML getAttribute method.
Example
The following example uses the getAttribute method to get an attribute on an object participating in userData persistence.
Sample Code
<HEAD> <STYLE> .userData {behavior:url(#default#userdata);} </STYLE> <SCRIPT> function fnGet(){ oPersistInput.load("oXMLStore"); oPersistInput.value=oPersistInput.getAttribute("sPersistAttr"); } function fnSet(){ oPersistInput.setAttribute("sPersistAttr",oPersistInput.value); oPersistInput.save("oXMLStore"); } function fnRem(){ oPersistInput.removeAttribute("sPersistAttr"); oPersistInput.save("oXMLStore"); } </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>
Applies To
HTML A, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BGSOUND, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, H1, H2, H3, H4, H5, H6, HEAD, HR, HTML, I, IFRAME, IMG, INPUT, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, META, NEXTID, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, STYLE, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, WBR, XMP Behaviors saveFavorite, saveHistory, userData
See Also
DHTML Behaviors, Persistence Overview
Does this content meet your programming needs? Write us!
© 1998 Microsoft Corporation. All rights reserved. Terms of use.