The Link object is a piece of text, an image or an area of an image that loads a hypertext link reference into the target window when selected.
Area objects are also a type of Link object. A link can
be created either by using the HTML 'A' or 'AREA' tags, or by calling
the String.link method. Each 'A' or 'AREA' tag that has an HREF
attribute is placed by the JavaScript engine in an array in the document.links
property. A Link object can then be accessed by indexing this array.
A Link object is a Location object and shares the same
properties. When you click a Link object, the destination document's
referrer property then contains the URL of the source page. A
link can also be used to execute JavaScript code rather than to reference
a hyperlink.
<script type="text/javascript">
function write_hello()
{
document.write("Hello World!")
}
</script>
<a href="javascript:write_hello()">GREETINGS</a>
This code simply creates a function to display the message "Hello World!" which is then called if the user clicks on the 'GREETINGS' link.
document.write("AUTHORS".link("Authors.htm#author"))
This example demonstrates the creation of a link to an anchor in the 'Authors.htm' page using the String.link method.
Syntax: object.hash
The hash property is a string beginning with a hash (#), that specifies an anchor name in an HTTP URL.
Syntax: object.host
The host property is a string comprising of the hostname and host strings.
Syntax: object.hostname
The hostname property specifies the server name, subdomain and domain name (or IP address) of a URL.
Syntax: object.href
The href property is a string specifying the entire URL, and of which all other Link properties are substrings.
Syntax: object.pathname
The pathname property is a string portion of a URL specifying how a particular resource can be accessed.
Syntax: object.port
The port property is a string specifying the communications port that the server uses.
Syntax: object.protocol
The protocol property is the string at the beginning of a URL, up to and including the first colon (:), which specifies the method of access to the URL.
Syntax: object.search
The search property is a string beginning with a question mark that specifies any query information in an HTTP URL.
Syntax: object.target
The target property is a string specifying the window that displays the contents of a clicked hyperlink.
Syntax: object.text
The text property is a string containing the text of a corresponding 'A' tag.
Syntax: object.handleEvent(event)
The HandleEvent method invokes the handler for the specified event.