JavaScripture
Contribute via GitHub Feedback

Location : Object

Location describes the url of the current page. It is available through the window.location property. See also History.

Here's an example:
PropertyValue
href'http://username:[email protected]:80/pathname?search=terms#hash'
protocol'http:'
username'username'
password'password'
hostname'www.javascripture.com'
port'80'
host'www.javascripture.com:80'
origin'http://www.javascripture.com:80'
pathname'/pathname'
search'?search=terms'
hash'#hash'

Instance Properties

hash : String

The hash portion of Location. This is the '#' and everything following it. Use the window.onhashchange event to listen for changes to the hash.

Example:

Run

Results:

 

host : String

The host of the current Location. Composed of hostname and port (if any).

Example:

Run

Results:

 

hostname : String

The hostname of the current Location.

Example:

Run

Results:

 

href : String

The concatenation of all parts of the Location into one string. You can set href to cause the browser to navigate to a new location.

Example:

Run

Results:

 

origin : String  

The origin of the current Location. Composed of the protocol, hostname, and port (if any).

Example:

Run

Results:

 

password : String

The password of Location or undefined if not specified.

Example:

Run

Results:

 

pathname : String

The path of Location.

Example:

Run

Results:

 

port : String

The port of the current Location. May be '' if the port is the not specified in the Location.

Example:

Run

Results:

 

protocol : String

The protocol of the current Location.

Example:

Run

Results:

 

search : String

The search portion of Location. This is the '?' and everything following it.

Example:

Run

Results:

 

username : String

The username of Location or undefined if not specified.

Example:

Run

Results:

 

Instance Methods

assign(url : String) : undefined

Navigates to the specified url. The current page is stored in the browser's navigation stack.

reload() : undefined

Reloads the current page.

replace(url : String) : undefined

Navigates to the specified url. The current page is removed from the browser's navigation stack.