Link Object (same as Area)
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
Events
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
Properties |
Description |
|
We will use the link "http://www.mysite.com/good.htm#section2"
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: www.mysite.com). |
hostname |
Specifies the hostname portion of the
link (ie: www.mysite.com). |
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. |
Examples
onClick
<a href="#" onClick="alert('Welcome to Computer Support Group Online!');
return false">Computer Support Group Online</a>
CSGNetwork.Com
onMouseover
<a href="http://www.dynamicdrive.com" onMouseover="window.status='#1 DHTML site online'; return true",
onMouseout="window.status=''">Dynamic Drive</a>
CSGNetwork Glossary