Name
Link: a hyperlink or anchor in an HTML document — DOM Level 0: Node → Element → HTMLElement → Link
Properties
The most important property of a Link is its href
, which is the URL to which it links.
The Link object also defines a number of other properties that hold
portions of the 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
-
String hash
Specifies the anchor portion of the Link’s URL, including the leading hash (#) mark—for example, “#results”. 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 the
name
attribute of the<a>
tag. (seeAnchor
).-
String host
Specifies the hostname and port portions of a Link’s URL—for example, "http://www.oreilly.com:1234“.
-
String hostname
Specifies the hostname portion of a Link’s URL—for example, "http://www.oreilly.com“.
-
String href
Specifies the complete text of the Link’s URL, unlike other Link URL properties that specify only portions of the URL.
-
String pathname
Specifies the pathname portion of a Link’s URL—for example, “/catalog/search.html”.
-
String port
Specifies the port portion of a Link’s URL—for example, “1234”.
-
String protocol
Specifies the protocol portion of a Link’s URL, including the trailing colon—for example, “http:”.
-
String search
Specifies the query portion of a Link’s URL, including the leading question mark—for ...
Get JavaScript: The Definitive Guide, 5th 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.