JavaScript Kit > JavaScript Reference > Here

Link Object (same as Area)

Last updated: June 20th, 2004

Each link on your page is represented by a corresponding link object in JavaScript, with events and properties as described below. You may also loop through every link on your page via the links collection:

document.links[] //links collection
document.links.length //the number of links on your page

Related Tutorials


Events Description
onClick Code is executed when user clicks on link. Return false to disable link. Example(s)
onDblClick Code is executed when user double clicks on link.
onMouseDown Code is executed when user holds mouse down over link.
onMouseUp Code is executed when user releases mouse from link.
onMouseOver Code is executed when user moves mouse over link. Example(s).
onMouseOut Code is executed when user moves mouse out of link.


Properties Description

We will use the link "" as basis below to explain the various properties.

hash Specifies the anchor portion of the link. (ie: "section2").
host Specifies the host and domain name of a network host. (ie:
hostname Specifies the hostname portion of the link (ie:
href Specifies the entire link.
pathname Specifies the path name of the link (ie: /good.htm).
port Specifies the port portion of the link.
protocol Specifies the protocol portion of the link (ie: http:).
search Specifies the query portion of the link (ie: ?sort=alpha)
target Specifies the target attribute of the link.



<a href="#" onClick="alert('Welcome to JavaScript Kit!'); return false">JavaScript Kit</a>

JavaScript Kit


<a href="" onMouseover="window.status='#1 DHTML site online'; return true", onMouseout="window.status=''">Dynamic Drive</a>

Dynamic Drive

Reference List

Right column

CopyRight (c) 2018 JavaScript Kit. NO PART may be reproduced without author's permission. Contact Info