Export (0) Print
Expand All

setAttribute Method

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

Sets the value of the specified attribute.

Syntax

object.setAttribute(sAttrName, vAttrValue)

Parameters

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

Return Value

No return value.

Remarks

If the specified attribute is not already present, the setAttribute method adds the attribute to the object and sets the value.

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 behavior and saveSnapshot behavior, and recommended for the saveHistory behavior and saveFavorite behavior.

This method overrides the DHTML setAttribute method.

Example

This example uses the setAttribute method to set an attribute on an object participating in userData persistence.


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

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/persistence/setAttribute_1.htm

Applies To

saveFavorite, saveHistory, userData

See Also

Community Additions

ADD
Show:
© 2014 Microsoft