AvailabilityJavaScript 1.0; enhanced in JavaScript 1.1 Inherits from/OverridesInherits from HTMLElement Synopsisdocument.links[] document.links.length PropertiesLink inherits properties from HTMLElement and defines the following properties. Many of the properties represent portions of a URL. For each of these properties, the example given is a portion of the following (fictitious) URL: http://www.oreilly.com:1234/catalog/search.html?q=JavaScript&m=10#results
MethodsLink inherits the methods of HTMLElement. Event HandlersLink inherits the event handlers of HTMLElement and defines special behavior for the following:
HTML SyntaxA Link object is created with standard <a> and </a> tags. The href attribute is required for all Link objects. If the name attribute is also specified, 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 JavaScript 1.1 and later, a Link object is also created by each <area> tag within a client-side image map. This is also standard HTML: <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 <area> tags 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 distinction between them. The destination of a hypertext link is a URL, of course, and many of the properties of the Link object specify the contents of that URL. The Link object is similar to the Location object, which also has a full set of URL properties. In the case of the Location object, these properties describe the URL of the currently displayed document. In addition to its properties, the Link object has three event handlers. 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. See AlsoAnchor, Location; HTMLAnchorElement in the DOM reference section |