259Chapter 15Generic HTML Element Objectscount++; setToolTip(elem); } title (Dedicated web hosting)

259Chapter 15Generic HTML Element Objectscount++; setToolTip(elem); }

title Property Lab



Roll the mouse over this paragraph a few times.
Then pause atop it to view the tooltip.

Related Item:window.statusproperty. uniqueIDValue:String.Read-Only Compatibility:WinIE5+, MacIE-, NN-, Moz-, Safari- You can let the WinIE5+ browser generate an identifier (idproperty) for a dynamically gener- ated element on the page with the aid of the uniqueIDproperty. You should use this featurewith care because the ID it generates at any given time may differ from the ID generated thenext time the element is created in the page. Therefore, you should use the uniqueIDprop- erty when your scripts require an unknown element to have an idproperty but the algo- rithms are not expecting any specific identifier. To guarantee that an element gets only one ID assigned to it while the object exists in mem- ory, assign the value via the uniqueIDproperty of that same object not some other object. Once you retrieve the uniqueIDproperty of an object, the property s value stays the same nomatter how often you access the property again. In general, you assign the value returned bythe uniqueIDproperty to the object s idproperty for other kinds of processing. (For exam- ple, the parameter of a getElementById()method requires the value assigned to the idproperty of an object.) ExampleListing 15-18 demonstrates the recommended syntax for obtaining and applying a browser- generated identifier for an object. After you enter some text into the text box and click the but- ton, the addRow()function appends a row to the table. The left column displays the identifiergenerated via the table row object s uniqueIDproperty. IE5+ generates identifiers in the format ms__idn , where nis an integer starting with zero for the current browser session. Because theaddRow()function assigns uniqueIDvalues to the row and the cells in each row, the integer foreach row is three greater than the previous one. There is no guarantee that future generations ofthe browser will follow this format, so do not rely on the format or sequence in your scripts. Listing 15-18: Using the uniqueID Property