Location Interface

Loading...

Overview

See MDN Location Interface

There are two objects that maintain a Location object:

  1. Window.location
  2. Document.location
For info on the historical differences, see What's the difference between window.location and document.location

Basic Properties

Basic Methods

location.assign()

Loads the resource at the URL provided by the given parameter. The location will be added to the browser history.

document.location.assign(url)

location.replace()

Replaces the current history location with the resource at the URL provided by the given parameter and loads that resource. The current page is no longer in the history, so after the new resource is loaded, using the browser back button will bypass this page.

document.location.replace(url)

location.reload()

Reloads the resource from the current URL. If the optional parameter is true, then reloads from the server; otherwise, reloads from the browser cache.

document.reload.reload(forcedReload)

location.toString()

document.location.toString()