| a | NN 6 IE 4 DOM 1 |
<a>
[window.]document.links[i]
[window.]document.anchors[i]
[window.]document.getElementById("elementID")
|
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 |
None.
|
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 |
Anchor-only a objects have no event handlers in Navigator through Version 4.
charset NN 6 IE 6 DOM 1 Character encoding of the document's content.
Read/Write 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 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.
Read/Write 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 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.
Read/Write 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 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.
Read/Write 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 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.
Read/Write Example
document.all.hotlink.dataSrc = "#DBSRC3";Value
Case-sensitive identifier of the data source.
Default
None.
hash NN 2 IE 3 DOM 1 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.
Read/Write Example
document.getElementById("myLink").hash = "section3"; document.links[2].hash = "section3";Value
String.
Default
None.
host NN 2 IE 3 DOM 1 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.
Read/Write 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 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.
Read/Write 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 Provides the URL specified by the element's href attribute.
Read/Write 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 Provides the language code of the content at the destination of a link. Requires that the href attribute or property also be set.
Read/Write Example
document.getElementById("myLink").hreflang = "DE";Value
Case-insensitive language code.
Default
None.
Methods NN n/a IE 4 DOM n/a 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.
Read/Write 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 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.
Read-only 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 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.
Read/Write 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 Returns just the filename, rather than the full URL, of the href attribute set for the element. Not available in IE 4/Macintosh.
Read-only Example
if (document.getElementById("myLink").nameProp == "logo2.gif") { ... }Value
String.
Default
None.
pathname NN 2 IE 3 DOM 1 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.
Read/Write 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 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.
Read/Write 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 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:".
Read/Write Example
document.getElementById("secureLink").protocol = "https:";Value
String.
Default
None.
protocolLong NN n/a IE 4 DOM n/a 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 .
Read-only Example
if (document.getElementById("myLink").protocolLong == "HyperText Transfer Protocol") { // statements for treating document as server file }Value
String.
Default
None
rel NN 6 IE 4 DOM 1 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.
Read/Write 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 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.
Read/Write 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 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.
Read/Write 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 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.
Read/Write Example
document.getElementById("myLink").shape = "circle";Value
Case-insensitive shape constant as string: default | rect | rectangle | circle | poly | polygon.
Default
rect
target NN 2 IE 3 DOM 1 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.
Read/Write 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 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.
Read-only Value
String value.
Default
None.
type NN 6 IE 6 DOM 1 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.
Read/Write 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 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.
Read/Write Example
document.getElementById("link3").urn = "http://www.megacorp.com";Value
Complete or relative URN as a string.
Default
None.
AbstractView See the window object.
acronym, cite, code, dfn, em, kbd, samp, strong, var NN 6 IE 4 DOM 1 All these objects reflect the corresponding HTML phrase elements of the same name. Each of these phrase elements provides a context for an inline sequence of content. Some of these elements are rendered in ways to distinguish themselves from running text. See the HTML element descriptions in Chapter 8 for details. From a scripted standpoint, all phrase element objects share the same set of properties, methods, and event handlers.
HTML Equivalent
<acronym> <cite> <code> <dfn> <em> <kbd> <samp> <strong> <var>Object Model Reference
[window.]document.getElementById("elementID")Object-Specific Properties
None.
Object-Specific Methods
None.
Object-Specific Event Handler Properties
None.
address NN n/a IE 4 DOM 1 The address object reflects the address element.
HTML Equivalent
<address>Object Model Reference
[window.]document.getElementById("elementID")Object-Specific Properties
None.
Object-Specific Methods
None.
Object-Specific Event Handler Properties
None.
all NN n/a IE 4 DOM n/a A collection of elements nested within the current element. A reference to document.all, for example, returns a collection (array) of all element objects contained by the document, including elements that may be deeply nested inside the document's first level of elements. The collection is sorted in source code order of the element tags. You can retrieve a reference to an element with its ID by any of the following syntaxes:
document.all.elementID document.all["elementID"] document.all("elementID"] document.all.item("elementID") document.all.namedItem("elementID")The W3C DOM equivalent (the document.getElementById( ) method) operates only from the document object, providing global reach to elements throughout the entire document.
Object Model Reference
elementReference.allObject-Specific Properties
length
Object-Specific Methods
item( )
namedItem( )
tags( )
urns( )
Object-Specific Event Handler Properties
None.
length NN n/a IE 4 DOM n/a Returns the number of elements in the collection.
Read-only Example
var howMany = document.all.length;Value
Integer.
item( ) NN n/a IE 4 DOM n/a
item(index[, subindex])Returns a single object or collection of objects corresponding to the element matching the index value (or, optionally, the index and subindex values).
Returned Value
One object or collection (array) of objects. If there are no matches to the parameters, the returned value is null.
Parameters
- index
- When the parameter is a zero-based integer, the returned value is a single element corresponding to the specified item in source code order (nested within the current element); when the parameter is a string, the returned value is a collection of elements whose id or name properties match that string.
- subindex
- If you specify a string value for the first parameter, you can use the second parameter to specify a zero-based index that retrieves the specified element from the collection whose id or name properties match the first parameter's string value.
namedItem( ) NN n/a IE 6 DOM n/a
namedItem(IDOrName)Returns a single object or collection of objects corresponding to the element matching the parameter string value.
Returned Value
One object or collection (array) of objects. If there are no matches to the parameters, the returned value is null.
Parameters
- IDOrName
- The string that contains the same value and case as the desired element's id or name attribute.
tags( ) NN n/a IE 4 DOM n/a
tags(tagName)Returns a collection of objects (among all objects nested within the current element) whose tags match the tagName parameter.
Returned Value
A collection (array) of objects. If there are no matches to the parameters, the returned value is an array of zero length.
Parameters
- tagName
- A case-insensitive string that contains the element tag name only (no angle brackets), as in document.all.tags("p").
urns( ) NN n/a IE 5(Win) DOM n/a
urns(URN)Returns a collection of nested element objects that have behaviors attached to them and whose URNs match the URN parameter.
Returned Value
A collection (array) of objects. If there are no matches to the parameters, the returned value is an array of zero length.
Parameters
- URN
- A string with a local or external behavior file URN.
anchors NN 2 IE 3 DOM 1 A collection of all a elements with assigned name attributes that make them behave as anchors (instead of links). Collection members are sorted in source code order. Navigator and Internet Explorer let you use array notation to access a single anchor in the collection (e.g., document.anchors[0], document.anchors["section3"]). Internet Explorer 4 also allows the index value to be placed inside parentheses instead of brackets (e.g., document.anchors(0)). If you want to use the anchor's name as an index value (always as a string identifier), be sure to use the value of the name attribute, rather than the id attribute. To use the id attribute in a reference to an anchor, access the object via a document.all.elementID (in IE only) or document.getElementById("elementID") reference.
Object Model Reference
document.anchorsObject-Specific Properties
length
Object-Specific Methods
item( )
namedItem( )
tags( )
urns( )
Object-Specific Event Handler Properties
None.
length NN 2 IE 3 DOM 1 Returns the number of elements in the collection.
Read-only Example
var howMany = document.anchors.length;Value
Integer.
item( ) NN 6 IE 4 DOM 1
item(index[, subindex]) item(index)Returns a single anchor object or collection of anchor objects corresponding to the element matching the index value (or, optionally in IE, the index and subindex values).
Returned Value
One anchor object or collection (array) of anchor objects. If there are no matches to the parameters, the returned value is null.
Parameters
- index
- When the parameter is a zero-based integer (required in Netscape 6), the returned value is a single element that corresponds to the specified item in source code order (nested within the current element). When the parameter is a string, the returned value is a collection of elements whose id or name properties match that string.
- subindex
- In IE only, if you specify a string value for the first parameter (IE only), you can use the second parameter to specify a zero-based index that retrieves the specified element from the collection with id or name properties that match the first parameter's string value.
namedItem( ) NN 6 IE 6 DOM 1
namedItem(IDOrName)Returns a single anchor object or collection of anchor objects corresponding to the element matching the parameter string value.
Returned Value
One anchor object or collection (array) of anchor objects. If there are no matches to the parameters, the returned value is null.
Parameters
- IDOrName
- The string that contains the same value as the desired element's id or name attribute.
tags( ) NN n/a IE 4 DOM n/a
tags(tagName)Returns a collection of objects (among all objects nested within the current collection) with tags that match the tagName parameter. Implemented in all IE collections (see the all.tags( ) method), but redundant for collections of the same element type.
urns( ) NN n/a IE 5(Win) DOM n/a
urns(URN)See the all.urns( ) method.
applet NN 3 IE 4 DOM 1 The applet object reflects the applet element.
HTML Equivalent
<applet>Object Model Reference
[window.]document.appletName [window.]document.getElementById("elementID")Object-Specific Properties
align
alt
altHTML
archive
code
codeBase
dataFld
dataSrc
height
hspace
name
object
src
vspace
width
Object-Specific Methods
None.
Object-Specific Event Handler Properties
None.
align NN 6 IE 4 DOM 1 Defines the alignment of the element within its surrounding container. Only partially implemented in Netscape 6.2. See Section 8.1.5 at the beginning of Chapter 8 for the various meanings that different values bring to this property.
Read/Write Example
document.getElementById("myApplet").align = "center";Value
Any of the alignment constants: absbottom | absmiddle | baseline | bottom | left | middle | right | texttop | top.
Default
left
alt NN 6 IE 6 DOM 1 This is the text message to be displayed if the object or applet fails to load. There is little indication that setting this property on an existing applet object has any visual effect.
Read/Write Example
document.myApplet.alt= "Image Editor Applet";Value
Any quoted string of characters, but HTML tags are not interpreted.
Default
None.
altHTML NN n/a IE 4 DOM n/a Provides the HTML content to be displayed if the object or applet fails to load. This can be a message, static image, or any other HTML that best fits the scenario. There is little indication that setting this property on an existing applet object has any visual effect.
Read/Write Example
document.myApplet.altHTML = "<img src='appletAlt.gif'>";Value
Any quoted string of characters, including HTML tags.
Default
None.
archive NN 6 IE 6 DOM 6 Reflects the archive attribute of the applet element. Only partially implemented in the browsers. See the discussion of the archive attribute in Chapter 8.
Read-only Example
if (document.applets["clock"].archive == "myClock.zip") { // process for the found class file }Value
Case-sensitive URI as a string.
Default
None.
code NN 6 IE 4 DOM 1 Provides the name of the Java applet class file set to the code attribute. Not fully implemented in Netscape 7.
Read-only Example
if (document.applets["clock"].code == "XMAScounter.class") { // process for the found class file }Value
Case-sensitive applet class filename as a string.
Default
None.
codeBase NN 6 IE 4 DOM 1 Provides the path to the directory holding the class file designated in the code attribute. The codebase attribute does not name the class file, just the path. Not fully implemented in Netscape 7.
Read-only Example
if (document.applets["clock"].codeBase == "classes") { // process for the found class file directory }Value
Case-sensitive pathname, usually relative to the directory storing the current HTML document.
Default
None.
dataFld NN n/a IE 4 DOM n/a It is unclear how you would use this property with an applet object because the dataFld and dataSrc properties (as set in element attributes) are applied to individual param elements.
Read/Write Value
Case-sensitive identifier of the data source column.
Default
None.
dataSrc NN n/a IE 4 DOM n/a It's unclear how you would use this property with an applet object because the dataFld and dataSrc properties (as set in element attributes) are applied to individual param elements.
Read/Write Value
Case-sensitive identifier of the data source.
Default
None.
height, width NN 6 IE 4 DOM 1 Indicate the height and width in pixels of the element as set by the tag attributes. Changing the values does not necessarily change the actual rectangle of the applet after it has loaded. Not fully implemented in Netscape 7.
Read/Write Example
var appletHeight = document.myApplet.height;Value
Integer.
Default
None.
hspace, vspace NN 6 IE 4 DOM 1 Indicate the pixel measure of horizontal and vertical margins surrounding an applet. The hspace property affects the left and right edges of the element equally; the vspace affects the top and bottom edges of the element equally. These margins are not the same as margins set by style sheets, but they have the same visual effect.
Read/Write Example
document.getElementById("myApplet").hspace = 5; document.getElementById("myApplet").vspace = 8;Value
Integer of pixel count.
Default
0
name NN 6 IE 4 DOM 1 This is the identifier associated with the applet. Use the name when referring to the object in the form document.appletName.
Read-only 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.
object NN n/a IE 4 DOM n/a Returns a reference to the applet object so that a script can access a property or method of the applet whose name is identical to a property or method of the applet element object.
Read-only Value
Applet object (not the applet element object) reference.
Default
None.
src NN n/a IE 4 DOM n/a Internet Explorer defines this attribute as the URL for an associated file. The src property is not a substitute for the code and/or codebase properties.
Read-only Value
Complete or relative URL as a string.
Default
None.
vspace
See hspace.
width See height.
applets NN 2 IE 3 DOM 1 A collection of all the Java applets in the current element, sorted in source code order. Navigator and Internet Explorer let you use array notation to access a single applet in the collection (e.g., document.applets[0], document.applets["clockApplet"]). Internet Explorer allows the index value to be placed inside parentheses instead of brackets (e.g., document.applets(0)). If you wish to use the applet's name as an index value (always as a string identifier), use the value of the name attribute rather than the id attribute. To use the id attribute in a reference to an applet, access the object via a document.all.elementID (in IE only) or document.getElementById("elementID") reference.
Object Model Reference
document.applets[i]Object-Specific Properties
length
Object-Specific Methods
item( )
namedItem( )
length NN 2 IE 3 DOM 1 Returns the number of elements in the collection.
Read-only Example
var howMany = document.applets.length;Value
Integer.
item( ) NN 6 IE 4 DOM 1
item(index[, subindex]) item(index)Returns a single applet object or collection of applet objects corresponding to the element matching the index value (or, optionally in IE, the index and subindex values).
Returned Value
One applet object or collection (array) of applet objects. If there are no matches to the parameters, the returned value is null.
Parameters
- index
- When the parameter is a zero-based integer, the returned value is a single element corresponding to the specified item in source code order (nested within the current element); when the parameter is a string, the returned value is a collection of elements whose id or name properties match that string.
- subindex
- In IE only, if you specify a string value for the first parameter, you can use the second parameter to specify a zero-based index that retrieves the specified element from the collection whose id or name properties match the first parameter's string value.
namedItem( ) NN 6 IE 6 DOM 1
namedItem(IDOrName)Returns a single applet object or collection of applet objects corresponding to the element matching the parameter string value.
Returned Value
One applet object or collection (array) of applet objects. If there are no matches to the parameters, the returned value is null.
Parameters
- IDOrName
- The string that contains the same value as the desired element's id or name attribute.
area NN 3 IE 4 DOM 1 The area object reflects the area element, which defines the shape, coordinates, and destination of a clickable region of a client-side image map. Navigator and Internet Explorer treat an area object as a member of the links collection, since an area object behaves much like a link, but for a segment of an image.
HTML Equivalent
<area>Object Model Reference
[window.]document.links[i] [window.]document.getElementById("elementID")Object-Specific Properties
alt
coords
hash
host
hostname
href
noHref
pathname
port
protocol
search
shape
target
Object-Specific Methods
None.
Object-Specific Event Handler Properties
None.
alt NN 6 IE 4 DOM 1 Future nongraphical browsers may use the alt property setting to display a brief description of the meaning of the (invisible) image's hotspots.
Read/Write Example
document.getElementById("elementID").alt = "To Next Page";Value
Any quoted string of characters.
Default
None.
coords NN 6 IE 4 DOM 1 Defines the outline of the area to be associated with a particular link or scripted action. 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.
Read/Write Example
document.getElementById("mapArea2").coords = "25, 5, 50, 70";Value
Each coordinate is a pixel 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.
hash NN 2 IE 3 DOM 1 This is 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.
Read/Write Example
document.getElementById("mapArea2").hash = "section3";Value
String.
Default
None.
host NN 2 IE 3 DOM 1 Provides the combination of the hostname and port (if any) of the server of the destination document for the area 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.
Read/Write Example
document.getElementById("mapArea2").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 Provides the hostname of the server (i.e., a two-dot address consisting of server name and domain) of the destination document for the area link. The hostname property does not include the port number.
Read/Write Example
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 This is the URL specified by the element's href attribute.
Read/Write Example
document.links[2].href = "http://www.megacorp.com";Value
String of complete or relative URL.
Default
None.
noHref NN 6 IE 4 DOM 1 Specifies whether the area defined by the coordinates has a link associated with it. When you set this property to true, scriptable browsers no longer treat the element as a link.
Read/Write Example
document.links[4].noHref = "true";Value
Boolean value: true | false.
Default
false
pathname NN 2 IE 3 DOM 1 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.
Read/Write Example
document.getElementById("myLink").pathname = "/images/logoHiRes.gif";Value
String.
Default
None.
port NN 2 IE 3 DOM 1 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.
Read/Write Example
document.getElementById("myLink").port = "80";Value
String (a numeric value as string).
Default
None.
protocol NN 2 IE 3 DOM 1 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:".
Read/Write Example
document.getElementById("secureLink").protocol = "https:";Value
String.
Default
None.
search NN 2 IE 3 DOM 1 This is 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.
Read/Write Example
document.getElementById("searchLink").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 4 DOM 1 Indicates the shape of a server-side image map area with coordinates that are specified with the coords attribute.
Read/Write Example
document.getElementById("area51").shape = "circle";Value
Case-insensitive shape constant as string: default | rect | rectangle | circle | poly | polygon.
Default
RECT (IE); empty string but rect implied (Netscape 6).
target NN 2 IE 3 DOM 1 This is the name of the window or frame that is to receive content as the result of navigating to an area 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, you can omit the target attribute in the code, but assign a value to the area element's target property by script after the page loads.
Read/Write Example
document.getElementById("homeArea").target = "_blank";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.
areas NN 6 IE 4 DOM 1 A collection of all area elements associated with a map element. Notice that individual items of an areas collection are also members of the document-wide links collection (document.links[] array). But the members of an areas collection are local to a single map element.
Object Model Reference
document.getElementById("mapElementID").areasObject-Specific Properties
length
Object-Specific Methods
item( )
namedItem( )
tags( )
urns( )
length NN 6 IE 4 DOM 1 Returns the number of elements in the collection.
Read-only Example
var howMany = document.areas.length;Value
Integer.
item( ) NN 6 IE 4 DOM 1
item(index[, subindex]) item(index)Returns a single area object or collection of area objects corresponding to the element matching the index value (or, optionally in IE, the index and subindex values).
Returned Value
One area object or collection (array) of area objects. If there are no matches to the parameters, the returned value is null.
Parameters
- index
- When the parameter is a zero-based integer, the returned value is a single element corresponding to the specified item in source code order (nested within the current element); when the parameter is a string, the returned value is a collection of elements whose id or name properties match that string.
- subindex
- In IE only, if you specify a string value for the first parameter, you can use the second parameter to specify a zero-based index that retrieves the specified element from the collection whose id or name properties match the first parameter's string value.
namedItem( ) NN 6 IE 6 DOM 1
namedItem(IDOrName)Returns a single area object or collection of area objects corresponding to the element matching the parameter string value.
Returned Value
One area object or collection (array) of area objects. If there are no matches to the parameters, the returned value is null.
Parameters
- IDOrName
- The string that contains the same value as the desired element's id or name attribute.
tags( ) NN n/a IE 4 DOM n/a
tags(tagName)Returns a collection of objects (among all objects nested within the current collection) with tags that match the tagName parameter. Implemented in all IE collections (see the all.tags( ) method), but redundant for collections of the same element type.
urns( ) NN n/a IE 5(Win) DOM n/a
urns(URN)See the all.urns( ) method.
Attr, attribute NN 6 IE 5 DOM 1 An abstract representation of an element's attribute name/value pair is an object known in the W3C DOM vernacular as the Attr object; in IE terminology, it is called an attribute object. They are different names for the same object. An attribute object is created in both environments via the document.createAttribute( ) method; the reference to the attribute object then becomes the parameter to an element's setAttributeNode( ) method to insert that attribute object into the element. For example:
var newAttr = document.createAttribute("author"); newAttr.value = "William Shakespeare"; document.getElementById("hamlet").setAttributeNode(newAttr);Some W3C DOM element methods (most notably, the getAttributeNode( ) method) return attribute objects, which have properties that may be accessed like any scriptable object.
In the W3C DOM abstract model, the Attr object inherits all properties and methods of the Node object. Some Node object properties, however, are not inherited by the attribute object in IE/Windows until Version 6, even though they are implemented for element and text nodes in Version 5.
HTML Equivalent
Any name/value pair inside a start tag.
Object Model Reference
[window.]document.getElementById("elementID").attributes[i] [window.]document.getElementById("elementID").attributes.item(i) [window.]document.getElementById("elementID").attributes.getNamedItem[attrName]Object-Specific Properties
expando
name
ownerElement
specified
value
Object-Specific Methods
None.
Object-Specific Event Handler Properties
None.
expando NN n/a IE 6 DOM n/a Returns Boolean true if the attribute, once it is inserted into an element, is not one of the native attributes for the element. This property is false for an attribute created by document.createAttribute( ) until the attribute is added to the element (via the setAttributeNode( ) method), at which time the property's value is reevaluated within the context of the element's native attributes.
Read-only Example
var isCustomAttr = document.getElementById("book3928").getAttributeNode("author").expando;Value
Boolean value: true | false.
Default
false
name NN 6 IE 5 DOM 1 This is the name portion of the name/value pair of the attribute. It is identical to the nodeName property of the Attr node. You may not modify the name of an attribute by script because other dependencies may lead to document tree confusion. Instead, replace the old attribute with a newly created one, the name of which is a required parameter of the document.createAttribute( ) method.
Read-only Example
if (myAttr.name == "author") { // process author attribute }Value
String value.
Default
Empty string, although creating a new attribute requires a name.
ownerElement NN 6 IE n/a DOM 2 Refers to the element that contains the current attribute object. Until a newly created attribute is inserted into an element, this property is null.
Read-only Example
if (myAttr.ownerElement.tagName == "fred") { // process attribute of <fred> element }Value
Element node reference.
Default
null
specified NN 6 IE 5 DOM 1 Returns Boolean true if the value of the attribute is explicitly assigned in the source code or adjusted by script. If the browser reflects an attribute that is not explicitly set (IE does this), the specified property for that value is false, even though the attribute may have a default value determined by the document's DTD. The W3C DOM Level 2 indicates that the specified property of a freshly created Attr object should be true, but both IE 6 and Netscape 6.2 and later leave it false until the attribute is inserted into an element.
Read-only Example
if (myAttr.specified) { // process attribute whose value is something other than DTD default }Value
Boolean value: true | false.
Default
false
value NN 6 IE 6 DOM 1 Provides the value portion of the name/value pair of the attribute. Identical to the nodeValue property of the Attr node, as well as data accessed more directly via an element's getAttribute( ) and setAttribute( ) methods. If you create a new attribute object, you can assign its value via the value property prior to inserting the attribute into the element. Attribute node values are always strings, including in IE, which otherwise allows Number or Boolean data types for the corresponding properties.
Read/Write Example
document.getElementById("hamlet").getAttributeNode("author").value = "Shakespeare";Value
String value.
Default
Empty string, except in IE/Windows, which returns the string undefined (that is, not a value whose type evaluates to the undefined value).
attributes, NamedNodeMap NN 6 IE 5 DOM 1 The object returned by the attributes property of every W3C DOM element object is a collection (array) of references to Attr (a.k.a. attribute) objects. An attribute type of node always has a name associated with it, which opens the way for methods of the collection of such nodes to access them directly by name, rather than iterating through the array in search of a matching node name. In the W3C DOM structure, the abstract representation of this array of named nodes is called the NamedNodeMap object, which shares some properties and methods of the IE attributes object. Since both objects refer to the same parts of a document tree, they are treated here together. A couple of other W3C DOM collections are also of the NamedNodeMap variety, but your primary contact with the NamedNodeMap in HTML documents is as a collection of Attr objects. Collection members are sorted in source code order.
There are more direct ways to access an attribute of an element (such as the getAttribute( ) or getAttributeNode( ) methods of all elements). The property and methods shown here, however, assume that your script has been handed a collection of attributes independent of their host element, and your processing starts from that point.
Object Model Reference
elementReference.attributesObject-Specific Properties
length
Object-Specific Methods
getNamedItem( )
getNamedItemNS( )
item( )
removeNamedItem( )
removeNamedItemNS( )
setNamedItem( )
setNamedItemNS( )
Object-Specific Event Handler Properties
None.
length NN 6 IE 5 DOM 1 Returns the number of elements in the collection.
Read-only Example
var howMany = document.getElementById("myTable").attributes.length;Value
Integer.
getNamedItem( ) NN 6 IE 6 DOM 1
getNamedItem("attributeName")Returns a single Attr object corresponding to the attribute whose node name matches the parameter value.
Returned Value
Reference to one Attr object. If there is no match to the parameter value, the returned value is null.
Parameters
- attributeName
- String corresponding to the name portion of an attribute's name/value pair.
getNamedItemNS( ) NN 6 IE n/a DOM 2
getNamedItemNS("namespaceURI", "localName")Returns a single Attr object with a local name and namespace URI that match the parameter values.
Returned Value
Reference to one Attr object. If there is no match to the parameter values, the returned value is null.
Parameters
- namespaceURI
- URI string matching a URI assigned to a label earlier in the document.
- localName
- The local name portion of the attribute.
item( ) NN 6 IE 5 DOM 1
item(index)Returns a single Attr object corresponding to the element matching the index value.
Returned Value
Reference to one Attr object. If there is no match to the index value, the returned value is null. Unlike some other collections in IE, a string index value is not allowed for the attributes object.
Parameters
- index
- A zero-based integer corresponding to the specified item in source code order.
removeNamedItem( ) NN 6 IE 6 DOM 1