JavaScript Location

Summary: in this tutorial, you will learn about the JavaScript Location object and how to manipulate the location effectively.

The Location object represents the current location (URL) of a document. You can access the Location object by referencing the location property of the window or document object.

Both window.location and document.location link to the same Location object.

JavaScript Location properties

Suppose that the current URL is:

http://localhost:8080/js/index.html?type=listing&page=2#title
Code language: JavaScript (javascript)

The following picture illustrates the properties of the Location object: