Location object



Location Object

The Location object contains information about the current URL.

The Location object is part of the window object and can be accessed through the window.Location property.

NoteNote: There is no public standard for Location objects, but all browsers support this object.


Location Object Properties

PropertiesDescription
hashReturns the anchor portion of a URL
hostReturns the host name and port of a URL
hostnameReturn the host name of the URL
hrefReturn the complete URL
pathnameThe returned URL path name.
portReturns the port number used by a URL server
protocolReturns a URL protocol
searchReturns the query part of a URL

Location object method

MethodDescription
assign()Load a new document
reload()Reload the current document
replace()Replace the current document with a new one