JavaScript Kit > JavaScript Reference > Here


Last updated: July 6th, 2008

Location contains information about the current URL of the browser. The most common usage of Location is simply to use it to automatically navigate the user to another page:

<script type="text/javascript">

Related Tutorials


Properties Description

We will use the URL "" as basis below to explain the various properties.

hash Specifies the anchor portion of the URL, including the leading hash. (ie: "#section2").
host Specifies the hostname and port (if available) of a URL. (ie: "" or "").
hostname Specifies the hostname portion of the URL (ie: "").
href Specifies the entire URL.
pathname Specifies the path name of the URL (ie: "/good.htm").
port Specifies the port portion of the URL (ie: "563" within the host "").
protocol Specifies the protocol portion of the URL, including the trailing colon (ie: "http:" or "https:").
search Specifies the query portion of the URL, including the question mark (ie: "?sort=alpha")


Note: "[]" surrounding a parameter below means the parameter is optional.

Methods Description
reload([forceGet]) Reloads the current document. If "forceGet" set to true, document is completely reloaded even if server reports it hasn't been modified since last reload. Default is false.
replace(url) Loads the specified URL over the current history entry. Example(s)



location.replace("") //Loads in browser and overwrites the most recent history entry with it.

Reference List

Right column

CopyRight (c) 2018 JavaScript Kit. NO PART may be reproduced without author's permission. Contact Info