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 ...
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.