Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Location object


May 06, 2021 JavaScript with HTML DOM Reference book


Table of contents


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 window. The Location property accesses it.

Location object Note: There is no public standard applied to the Location object, but it is supported by all browsers.


Location object properties

Property Describe
hash Returns the anchor portion of a URL
host Returns the host name and port of a URL
hostname Returns the host name of the URL
Href Return the full URL
pathname The name of the URL path returned.
port Returns the port number used by a URL server
protocol Returns a URL protocol
search Returns the query section of a URL

Location object method

Method Description
assign() Load a new document
reload() Reload the current document
replace() Replace the current document with a new document