316Part IIIDocument Objects Referenceview. Any onFocusevent handler defined (Web site builder)

316Part IIIDocument Objects Referenceview. Any onFocusevent handler defined for the element fires when setActive()is invoked, without the browser giving the element focus. ExampleUse The Evaluator (Chapter 13) to compare the setActive()and focus()methods. Withthe page scrolled to the top and the window sized so that you cannot see the sample check- box near the bottom of the page, enter the following statement into the top text box: document.forms[1].myCheckbox.setActive() Scroll down to see that the checkbox has operational focus (press the spacebar to see). Now, scroll back to the top and enter the following: document.forms[1].myCheckbox.focus() This time, the checkbox gets focus and the page automatically scrolls the object into view. Related Item:focus()method. setAttribute( attributeName , value[, caseSensitivity]) Returns:Nothing. Compatibility:WinIE4+, MacIE4+, NN6+, Moz1+, Safari1+ The setAttribute()method assigns a new value to an existing attribute of the currentobject or inserts an entirely new attribute name value pair among the attributes of the cur- rent object. This method represents an alternative syntax to setting a property of the objectdirectly. The W3C DOM Level 2 standard recommends getAttribute()and setAttribute()forreading and writing element object attribute values, rather than reading and writing thosevalues by way of their corresponding properties. While using these methods is certainlyadvisable for XML elements, the same DOM standard sends conflicting signals by defining allkinds of properties for HTML element objects. Browsers, of course, will support access viaproperties well into the future, so don t feel obligated to change your ways just yet. The first two parameters of setAttribute()are required. The first is the name of theattribute. The default behavior of this method respects the case of the attribute name. Therefore, if you use setAttribute()to adjust the value of an existing attribute in defaultmode, the first parameter must match the case of the attribute as known by the object modelfor the current document. Remember that all names of all attributes assigned as inline sourcecode attributes are automatically converted to lowercase letters. A value you assign to the attribute is the second parameter. For cross-browser compatibility, the value should be either a string or Boolean data type. IE provides an optional third parameter to control the case-sensitivity issue for the attributename. The default value (true) has a different impact on your object depending on whether youuse setAttribute()to assign a new attribute or reassign an existing one. In the former case, the third parameter as truemeans that the attribute name assigned to the object observes thecase of the first parameter. In the latter case, the third parameter as truemeans that theattribute isn t reassigned unless the first parameter matches the case of the attribute currentlyassociated with the object. Instead, a new attribute with a different case sequence is created. Attempting to manage the case-sensitivity of newly created attributes is fraught with peril, especially if you try to reuse names but with different case sequences. I strongly recommendusing default case-sensitivity controls for setAttribute()and getAttribute(). NoteelementObject.setActive()