Javascript Location

The JavaScript Location object is used to get or set the current URL information. The Location object is part of the window object and can be accessed through the window.location property.

Location object is used to get the URL address information, or refresh the current page, page redirects, etc., can be seen below the various properties and methods listed.

Location object properties

  • location.hash : Set or retrieves the anchor in the URL
  • : Set or get the URL host (including the port number)
  • location.hostname : Set or retrieves the host name in the URL
  • location.href : Set or get the full URL (page redirect application)
  • location.pathname : Set or retrieves the path in the URL
  • location.port : Set or retrieves the port number in the URL
  • location.protocol : Set or retrieves the protocol used by the URL
  • : Set or get the URL in the query string (usually the? Symbol behind the content)

Location object method

History object has the following three methods :

  • location.assign() : loading a new page of the document
  • location.reload() : reload (refresh) the current page
  • the location.replace() : replace the current document with a new document

Copyright 2014-2017 by All Rights Reserved.