Name
Link — a hypertext link
Availability
JavaScript 1.0; enhanced in JavaScript 1.1
Inherits from/Overrides
Inherits from HTMLElement
Synopsis
document
.links[]document
.links.length
Properties
Link 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
-
hash
A read/write string property that specifies the anchor portion of the Link’s URL, including the leading hash (#) mark. For example: “#result”. This anchor portion of a URL refers to a named position within the document referenced by the Link. In HTML files, positions are named with anchors created with the
<a name="
anchor_name
">
tag.-
host
A read/write string property that specifies the hostname and port portions of a Link’s URL. For example, “www.oreilly.com:1234”.
-
hostname
A read/write string property that specifies the hostname portion of a Link’s URL. For example “www.oreilly.com”.
-
href
A read/write string property that specifies the complete text of the Link’s URL, unlike other Link URL properties that specify only portions of the URL.
-
pathname
A read/write string property that specifies the pathname portion of a Link’s URL. For example “/catalog/search.html”.
-
port
A read/write string (not a number) property that specifies the port portion of a Link’s URL. For example “1234”. ...
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.