Link ObjectNameLink Object---a hypertext linkAvailabilityNavigator 2.0, Internet Explorer 3.0; enhanced in Navigator 3.0 Synopsis
document.links[] document.links.length Properties
Event Handlers
HTML SyntaxA Link object is created with standard <A> and </A> tags, with the addition of the onClick, onMouseOver and onMouseOut event-handler attributes. The HREF attribute is required for all Link objects. If the NAME attribute is also specified, then an Anchor object is also created:
<A HREF="url" the destination of the link [ NAME="anchor_tag" ] creates an Anchor object [ TARGET="window_name" ] where the new document should be displayed [ onClick="handler" ] invoked when link is clicked [ onMouseOver="handler" ] invoked when mouse is over link [ onMouseOut="handler" ] invoked when mouse leaves link > link text or image the visible part of the link </A> In Navigator 3.0 and later, a Link object is also created by each <AREA> tag within a client-side image map. This is also standard HTML with the addition of event-handler tags:
<MAP NAME="map_name"> <AREA SHAPE="area_shape" COORDS=coordinates HREF="url" the destination of the link [ TARGET="window_name" ] where the new document should be displayed [ onClick="handler" ] invoked when area is clicked [ onMouseOver="handler" ] invoked when mouse is over area [ onMouseOut="handler" ] invoked when mouse leaves area > ... </MAP> DescriptionThe Link object represents a hypertext link or a clickable area of a client-side image map in an HTML document. All links created with the <A> (and in Navigator 3.0 the <AREA>) tag are represented by Link objects and stored in the links[] array of the Document object. Note that links created by both the <A> and <AREA> tags are stored in the same array--there is no real distinction between them, and there is no special Area object that represents hypertext links in an image map. The Link object can be thought of as a specialized form of the URL object. The destination of a hypertext link is a URL, of course, and the Link object has all of the properties of the URL object which describe that destination. These protocol, hostname, pathname and other URL properties are all documented under the URL object. The Link object is also related to the Location object, which also has a full set of URL properties that describe the URL of the currently displayed document. The Link object has an additional target property and three event handlers that are not shared by the URL object or Location objects, however. The target property specifies a window name into which the document referred to by the hypertext link should be loaded. And the onmouseover(), onclick(), and onmouseout() event handlers specify code to be executed when the mouse passes over the hypertext link, clicks on it, and moves off or out of the link's region of the screen. UsageIn HTML parlance, hypertext links are sometimes called "anchors" because they are created with the <A> tag, which is used both for links to other URLs and for creating named link destinations within a document. This is a confusing usage that should be avoided; in JavaScript, a hypertext link is a Link object, and a named destination for a link is an Anchor object. |
|