labelNN 6 IE 4 DOM 1  

  

The label object reflects the label element.

 
HTML Equivalent
 
<label>
 
Object Model Reference
 
[window.]document.getElementById("elementID")
 
Object-Specific Properties
 
dataFlddataFormatAsdataSrcformhtmlFor
 
Object-Specific Methods

None.

 
Object-Specific Event Handler Properties

None.

accessKeyNN n/a IE 4 DOM 1  

Read/Write  

This is single character key that either gives focus to an element (in some browsers) or activates a form control or link action. The browser and operating system determine if the user must press a modifier key (e.g., Ctrl, Alt, or Command) with the access key to activate the link. In Windows versions of IE 5 and later and Netscape 6, the Alt key is required and the key is not case-sensitive. For Macintosh versions of IE 5 and later and Netscape 6, the Ctrl modifier key is required to effect the action.

 

Although listed here as a widely shared property, that isn't strictly the case across all implementations. Netscape 6 (per the W3C DOM) recognizes this property only for the following elements: a, area, button, input, label, legend, and textarea. To this list, IE 4 adds applet, body, div, embed, isindex, marquee, object, select, span, table, and td (but removes label and legend). IE 5 adds every other renderable element, but with a caution. Except for input and other form-related elements, you must also assign a tabindex attribute or tabIndex property value to the IE 5 and later element (even if it's simply a value of zero for all) to let the accelerator key combination bring focus to the element. As of Version 7, Netscape does not alter UI behavior if a script changes the property's value.

 
Example
 
document.links[3].accessKey = "n";
 
Value

Single alphanumeric (and punctuation) keyboard character.

 
Default

Empty string.

dataFldNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding to associate a remote data source column name with the displayed text of the input element label. A datasrc attribute must also be set for the element. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only for text data sources in IE 5 for the Macintosh.

 
Example
 
document.getElementById("myLabel").dataFld = "labelText";
 
Value

Case-sensitive string identifier of the data source column.

 
Default

None.

dataFormatAsNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding, this property advises the browser whether the source material arriving from the data source is to be treated as plain text or as tagged HTML. Works only for text data sources in IE 5 for the Macintosh.

 
Example
 
document.forms[0].myLabel.dataFormatAs = "html";
 
Value

IE 4 recognizes two possible settings: text | html.

 
Default

text

dataSrcNN n/a IE 4 DOM n/a  

Read/Write  

Used with IE data binding to specify the ID of the page's object element that loads the data source object for remote data access. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only for text data sources in IE 5 for the Macintosh.

 
Example
 
document.getElementById("myLabel").dataSrc = "DBSRC3";
 
Value

Case-sensitive identifier of the data source.

 
Default

None.

formNN 6 IE 5(Mac)/6(Win) DOM 1  

Read-only  

Returns a reference to the next outermost form element object in the document tree. Multiple label element objects within the same form element reference the same form element object.

 
Example
 
var theForm = document.getElementById("myLabel").form;
 
Value

Reference to a form element object.

 
Default

None.

htmlForNN 6 IE 4 DOM 1  

Read/Write  

Provides the element id of the input element to which the label is associated (the value of the for attribute). Binds the label element to a particular input element.

 
Example
 
document.getElementById("label3").htmlFor = "chkbox3";
 
Value

String.

 
Default

None.