a | NN 6 IE 4 DOM 1
The a object reflects the a element, regardless of whether the element is set up to be an anchor, link, or both. Early versions of Navigator and Internet Explorer treat this object only as a member of the links[] and/or anchors[] arrays of a document. Starting with IE 4 and Netscape 6, you can access the object through supported element object reference syntax (e.g., the document.all[] collection for IE or document.getElementById() for IE 5 and later and Netscape 6).
HTML Equivalent
    <a>
Object Model Reference
    [window.]document.links[i]
    [window.]document.anchors[i]
    [window.]document.getElementById("elementID")
Object-Specific Properties
charset | coords | dataFld | dataFormatAs | dataSrc | hash
host | hostname | href | hreflang | Methods | mimeType
name | nameProp | pathname | port | protocol | protocolLong
rev | search | shape | target | text | type
urn |  |  |  |  |
Object-Specific Methods
None.
Object-Specific Event Handler Properties
Anchor-only a objects have no event handlers in Navigator through Version 4.
Handler | NN | IE | DOM
onblur | n/a | 4 | n/a
onclick | 2 | 3 | 2
ondblclick | 4 | 4 | n/a
onfocus | n/a | 4 | n/a
onhelp | n/a | 4 | n/a
onmousedown | 4 | 4 | 2
onmousemove | 6 | 4 | 2
onmouseout | 3 | 4 | 2
onmouseover | 2 | 3 | 2
onmouseup | 4 | 4 | 2

accessKey | NN 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.

blur( ) | NN 2 IE 3 DOM 1
Removes focus from the current object, at which time the object's onblur event fires. Note that the range of elements capable of focus and blur (both the event and method) is limited in all browsers except for more recent versions of IE (see the shared tabindex attribute in Chapter 8). Most reliably for backward compatibility, apply the blur( ) method to blatantly focusable elements, such as text input and textarea elements. Assigning the attribute onfocus="this.blur( );" to a text input element, for instance, is a crude but effective backward-compatible way to largely disable a field for browsers that do not provide genuine element disabling.
Use blur( ) and focus( ) methods in moderation on the same page. You can inadvertently trigger endless loops of blurring and focusing if alert dialog boxes are involved along the way. Moreover, be aware that when you invoke the blur( ) method on one object, some other object (perhaps the window object) receives an onfocus event. |

Parameters
None.
Returned Value
None.

charset | NN 6 IE 6 DOM 1
| Read/Write
Character encoding of the document's content. |

Example
    if (document.getElementById("myAnchor").charset == "csISO5427Cyrillic") {
        // process for Cyrillic charset
    }
Value
Case-insensitive alias from the character set registry (ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets).
Default
Determined by browser.

coords | NN 6 IE 6 DOM 1
| Read/Write
Defines the outline of an area to be associated with a particular link or scripted action. This property is a member of the a object, but really belongs to the area object, which inherits the properties of the a object. Coordinate values are entered as a comma-delimited list. If hotspots of two areas should overlap, the area that is defined earlier in the code takes precedence. |

Example
    document.getElementById("mapArea2").coords = "25, 5, 50, 70";
Value
Each coordinate is a length value, but the number of coordinates and their order depend on the shape specified by the shape attribute, which may optionally be associated with the element. For shape="rect", there are four coordinates (left, top, right, bottom); for shape="circle" there are three coordinates (center-x, center-y, radius); for shape="poly" there are two coordinate values for each point that defines the shape of the polygon.
Default
None.

dataFld | NN n/a IE 4 DOM n/a
| Read/Write
Used with IE data binding to associate a remote data source column value in lieu of an href attribute for a link. The 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 with text file data sources in IE 5/Mac. |

Example
    document.getElementById("hotlink").dataFld = "linkURL";
Value
Case-sensitive identifier of the data source column.
Default
None.

dataFormatAs | NN 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. |

Example
    document.getElementById("hotlink").dataFormatAs = "HTML";
Value
IE recognizes two possible settings: text | html.
Default
text

dataSrc | NN 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. Content from the data source to be inserted into the a element text is specified via the datafld property. Setting both the dataFld and dataSrc properties to empty strings breaks the binding between element and data source. Works only with text file data sources in IE 5/Mac. |

Example
    document.all.hotlink.dataSrc = "#DBSRC3";
Value
Case-sensitive identifier of the data source.
Default
None.

focus( ) | NN 2 IE 3 DOM 1
Gives focus from the current object, at which time the object's onfocus event fires. Note that the range of elements capable of focus and blur (both the event and method) is limited in all browsers except for more recent versions of IE (see the shared tabindex attribute in Chapter 8). Most reliably for backward compatibility, apply the focus( ) method to blatantly focusable elements, such as text input and textarea elements.
To give a text box focus and pre-select all the text in the box, use the sequence of focus( ) and select( ) methods on the element. If this sequence is to occur after windows change (such as after an alert dialog box closes), place the methods in a separate function, and invoke this function through the setTimeout( ) method following the alert( ) method for the dialog. This allows IE/Windows to sequence statement execution correctly. |

Parameters
None.
Returned Value
None.

hash | NN 2 IE 3 DOM 1
| Read/Write
Provides that portion of the href attribute's URL following the # symbol, referring to an anchor location in a document. Do not include the # symbol when setting the property. |

Example
    document.getElementById("myLink").hash = "section3";
    document.links[2].hash = "section3";
Value
String.
Default
None.

host | NN 2 IE 3 DOM 1
| Read/Write
This is the combination of the hostname and port (if any) of the server of the destination document for the link. If the port is explicitly part of the URL, the hostname and port are separated by a colon, just as they are in the URL. If the port number is not specified in an HTTP URL for IE, it automatically returns the default, port 80. |

Example
    document.getElementById("myLink").host = "www.megacorp.com:80";
    document.links[2].host = "www.megacorp.com:80";
Value
String of hostname optionally followed by a colon and port number.
Default
Depends on server.

hostname | NN 2 IE 3 DOM 1
| Read/Write
This is the hostname of the server (i.e., a "two-dot" address consisting of server name and domain) of the destination document for the link. The hostname property does not include the port number. |

Example
    document.getElementById("myLink").hostname = "www.megacorp.com";
    document.links[2].hostname = "www.megacorp.com";
Value
String of hostname (server and domain).
Default
Depends on server.

href | NN 2 IE 3 DOM 1
| Read/Write
Provides the URL specified by the element's href attribute. |

Example
    document.getElementById("myLink").href = "http://www.megacorp.com";
    document.links[2].href = "http://www.megacorp.com";
Value
String of complete or relative URL.
Default
None.

hreflang | NN 6 IE 6 DOM 1
| Read/Write
Provides the language code of the content at the destination of a link. Requires that the href attribute or property also be set. |

Example
    document.getElementById("myLink").hreflang = "DE";
Value
Case-insensitive language code.
Default
None.

Methods | NN n/a IE 4 DOM n/a
| Read/Write
Provides an advisory attribute about the functionality of the destination of a link. A browser could use this information to display special colors or images for the element content based on what the destination does for the user, but Internet Explorer does not appear to do anything with this information. |

Example
    document.links[1].Methods = "post";
Value
Any valid HTTP method as a string.
Default
None.

mimeType | NN n/a IE 4 DOM n/a
| Read-only
Returns a plain-language version of the MIME type of the destination document at the other end of the link specified by the href attribute. You could use this information to set the cursor type during a mouse rollover. Don't confuse this property with the navigator.mimeTypes[] array and individual mimeType objects that Netscape Navigator refers to. This is not available in IE 4/Macintosh. |

Example
    if (document.getElementById("myLink").mimeType == "GIF Image") {
        ...
    }
Value
A plain-language reference to the MIME type as a string.
Default
None.

name | NN 2 IE 3 DOM 1
| Read/Write
This is the identifier associated with an element that turns it into an anchor. You can also use the name as part of the object reference. |

Example
    if (document.links[12].name == "section3") {
        ...
    }
Value
Case-sensitive identifier that follows the rules of identifier naming: it may contain no whitespace, cannot begin with a numeral, and should avoid punctuation except for the underscore character.
Default
None.

nameProp | NN n/a IE 4 DOM n/a
| Read-only
Returns just the filename, rather than the full URL, of the href attribute set for the element. Not available in IE 4/Macintosh. |

Example
    if (document.getElementById("myLink").nameProp == "logo2.gif") {
        ...
    }
Value
String.
Default
None.

pathname | NN 2 IE 3 DOM 1
| Read/Write
Provides the pathname component of the URL assigned to the element's href attribute. This consists of all URL information following the last character of the domain name, including the initial forward slash symbol. |

Example
    document.getElementById("myLink").pathname = "/images/logoHiRes.gif";
    document.links[2].pathname = "/images/logoHiRes.gif";
Value
String.
Default
None.

port | NN 2 IE 3 DOM 1
| Read/Write
Provides the port component of the URL assigned to the element's href attribute. This consists of all URL information following the colon after the last character of the domain name. The colon is not part of the port property value. |

Example
    document.getElementById("myLink").port = "80";
    document.links[2].port = "80";
Value
String (a numeric value as string).
Default
None.

protocol | NN 2 IE 3 DOM 1
| Read/Write
Indicates the protocol component of the URL assigned to the element's href attribute. This consists of all URL information up to and including the first colon of a URL. Typical values are: "http:", "file:", "ftp:", and "mailto:". |

Example
    document.getElementById("secureLink").protocol = "https:";
Value
String.
Default
None.

protocolLong | NN n/a IE 4 DOM n/a
| Read-only
Provides a verbose description of the protocol implied by the URL of the href attribute or href property. Not supported in IE 4/Macintosh, and appears to be deprecated . |

Example
    if (document.getElementById("myLink").protocolLong ==
        "HyperText Transfer Protocol") {
        // statements for treating document as server file
    }
Value
String.
Default
None

recordNumber | NN n/a IE 4 DOM n/a
| Read-only
Used with IE data binding, returns an integer representing the record within the data set that generated the element (i.e., an element whose content is filled via data binding). Values of this property can be used to extract a specific record from an Active Data Objects (ADO) record set (see recordset property). Although this property is defined for all IE element objects, the other properties related to data binding belong to a subset of elements. |

Example
    <script for="tableTemplate" event="onclick">
    		    myDataCollection.recordset.absoluteposition = this.recordNumber;
    		    ...
    		</script>
Value
Integer.
Default
null

rel | NN 6 IE 4 DOM 1
| Read/Write
Defines the relationship between the current element and the destination of the link. Also known as a forward link, not to be confused in any way with the destination document whose address is defined by the href attribute. Mainstream browsers do not take advantage of this attribute for the a element, but you can treat the attribute as a kind of parameter to be checked and/or modified under script control. See the discussion of the a element's rel attribute in Chapter 8 for a glimpse of how this property may be used in the future. |

Value
Case-insensitive, space-delimited list of HTML 4.0 standard link types (as a single string) applicable to the element. Sanctioned link types are:
alternate | appendix | bookmark | chapter | contents
copyright | glossary | help | index | next
prev | section | start | stylesheet | subsection
Default
None.

rev | NN n/a IE 4 DOM 1
| Read/Write
Defines the relationship between the current element and the destination of the link. Also known as a reverse link. This property is not exploited yet in mainstream browsers, but you can treat the attribute as a kind of parameter to be checked and/or modified under script control. See the discussion of the a element's rev attribute in Chapter 8 for a glimpse of how this property may be used in the future. |

Value
Case-insensitive, space-delimited list of HTML 4.0 standard link types (as a single string) applicable to the element. See the rel property for sanctioned link types.
Default
None.

search | NN 2 IE 3 DOM 1
| Read/Write
Provides the URL-encoded portion of a URL assigned to the href attribute that begins with the ? symbol. A document that is served up as the result of the search also may have the search portion available as part of the window.location property. You can modify this property with a script. Doing so sends the URL and search criteria to the server. You must know the format of data (usually name/value pairs) expected by the server to perform this properly. |

Example
    document.getElementById("searchLink").search="?p=Tony+Blair&d=y&g=0&s=a&w=s&m=25";
    document.links[1].search="?p=Tony+Blair&d=y&g=0&s=a&w=s&m=25";
Value
String starting with the ? symbol.
Default
None.

shape | NN 6 IE 6 DOM 1
| Read/Write
Indicates the shape of a server-side image map area, with coordinates that are specified with the COORDS attribute. Intended for use by the area object, which inherits the properties of the a object. |

Example
    document.getElementById("myLink").shape = "circle";
Value
Case-insensitive shape constant as string: default | rect | rectangle | circle | poly | polygon.
Default
rect

tabIndex | NN 6 IE 4 DOM 1
| Read/Write
This is a number that indicates the sequence of this element within the tabbing order of all focusable elements in the document. Tabbing order follows a strict set of rules. Elements that have values other than zero assigned to their tabIndex properties are first in line when a user starts tabbing in a page. Focus starts with the element with the lowest tabIndex value and proceeds in order to the highest value, regardless of physical location on the page or in the document. If two elements have the same tabIndex values, the element that comes earlier in the document receives focus first. Next come all elements that either don't support the tabIndex property or have the value set to zero. These elements receive focus in the order in which they appear in the document.
The W3C DOM and Netscape 6 limit the tabIndex property to the following element objects: a, area, button, input, object, select, textarea. To this list, IE 4 adds applet, body, div, embed, isindex, marquee, span, table, and td. IE 5 adds every other renderable element. A negative value in IE (only) removes an element from tabbing order entirely.
Links and anchors cannot be tabbed to with the Mac version of IE 4, so the tabIndex property for a element objects is ignored in that version. |

Example
    document.getElementById("link3").tabIndex = 6;
Value
Integer.
Default
0

target | NN 2 IE 3 DOM 1
| Read/Write
Provides the name of the window or frame that is to receive content as the result of navigating to a link. Such names are assigned to frames by the frame element's name attribute; for subwindows, the name is assigned via the second parameter of the window.open( ) method. If you need the services of a target attribute to open a linked page in a blank browser window and you also need the HTML to validate under strict HTML or XHTML DTDs (see Chapter 1), you can omit the target attribute in the code, but you must assign a value to the a element's target property by script after the page loads. |

Example
    document.getElementById("homeLink").target = "_top";
    document.links[3].target = "_top";
Value
String value of the window or frame name, or any of the following constants (as a string): _parent | _self | _top | _blank. The _parent value targets the frameset to which the current document belongs; the _self value targets the current window; the _top value targets the main browser window, thereby eliminating all frames; and the _blank value creates a new window of default size.
Default
None.

text | NN 4 IE n/a DOM n/a
| Read-only
Returns the text between the a element's start and end tags. This property pre-dates the W3C DOM and should be used only if needed for Navigator 4. |

Value
String value.
Default
None.

type | NN 6 IE 6 DOM 1
| Read/Write
This is the MIME type of the destination document at the other end of the link specified by the href attribute. A browser might use this information to assist in preparing support for a resource requiring a multimedia player or plugin. |

Example
    if (document.getElementById("myLink").type == "image/jpeg") {
        ...
    }
Value
Case-insensitive MIME type. A catalog of registered MIME types is available from ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/.
Default
None.

urn | NN n/a IE 4 DOM n/a
| Read/Write
Indicates a Uniform Resource Name (URN) version of the destination document specified in the href attribute. This attribute is intended to offer support in the future for the URN format of URI, an evolving recommendation under discussion at the IETF (see RFC 2141). Although supported in IE, this attribute does not take the place of the href attribute. |

Example
    document.getElementById("link3").urn = "http://www.megacorp.com";
Value
Complete or relative URN as a string.
Default
None.