Name
Location: represents and controls browser location â JavaScript 1.0: Object â Location
Synopsis
locationwindow
.location
Properties
The properties of a Location object refer to the various portions of the current documentâs URL. In each of the following property descriptions, the example given is a portion of this (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 URL, including the leading hash (#) markâfor example, â#resultsâ. This portion of the document URL specifies the name of an anchor within the document.
-
host
A read/write string property that specifies the hostname and port portions of the URLâfor example, "http://www.oreilly.com:1234â.
-
hostname
A read/write string property that specifies the hostname portion of a URLâfor example, "http://www.oreilly.comâ.
-
href
A read/write string property that specifies the complete text of the documentâs URL, unlike other Location properties that specify only portions of the URL. Setting this property to a new URL causes the browser to read and display the contents of the new URL.
-
pathname
A read/write string property that specifies the pathname portion of a URLâfor example, â/catalog/search.htmlâ.
-
port
A read/write string (not a number) property that specifies the port portion of a URLâ for example, â1234â.
-
protocol
A read/write string property that specifies the protocol portion of a URL, ...
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.