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  

Read/Write  

Future nongraphical browsers may use the alt property setting to display a brief description of the meaning of the (invisible) image's hotspots.

 
Example
 
document.getElementById("elementID").alt = "To Next Page";
 
Value

Any quoted string of characters.

 
Default

None.

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.

coords NN 6 IE 4 DOM 1  

Read/Write  

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.

 
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.

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  

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.

 
Example
 
document.getElementById("mapArea2").hash = "section3";
 
Value

String.

 
Default

None.

host NN 2 IE 3 DOM 1  

Read/Write  

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.

 
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  

Read/Write  

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.

 
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  

Read/Write  

This is the URL specified by the element's href attribute.

 
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  

Read/Write  

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.

 
Example
 
document.links[4].noHref = "true";
 
Value

Boolean value: true | false.

 
Default

false

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";
 
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";
 
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.

shape NN 6 IE 4 DOM 1  

Read/Write  

Indicates the shape of a server-side image map area with coordinates that are specified with the coords attribute.

 
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).

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  

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.

 
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.