FANDOM


As an adaptation of content from the Mozilla Developer Center, this page is only available under the CC-BY-SA license, 2.5, or later.

A Location object represents the current URL. It may be set and/or retrieved either as a whole or in pieces. Operating on the Location itself is usually equivalent to using the href property, but sometimes (e.g., to call a string method) toString must be called to clarify.

Mozilla Microsoft
[1] [2]


Properties

hash

Data type string
Standard none
Documentation Mozilla Microsoft

The part of the URL that follows the # symbol, including the # symbol. For http://www.google.com/search?q=devmo#test this is #test.

host

Data type string
Standard none
Documentation Mozilla Microsoft

The host name and port number. For http://www.google.com/search?q=devmo#test this is [www.google.com]:80.

hostname

Data type string
Standard none
Documentation Mozilla Microsoft

The host name (without the port number or square brackets). For http://www.google.com/search?q=devmo#test this is www.google.com

href

Data type string
Standard none
Documentation Mozilla Microsoft

The entire URL. For http://www.google.com/search?q=devmo#test this is http://[www.google.com]:80/search?q=devmo#test.

pathname

Data type string
Standard none
Documentation Mozilla Microsoft

The path (relative to the host). For http://www.google.com/search?q=devmo#test this is /search.

port

Data type string
Standard none
Documentation Mozilla Microsoft

The port number of the URL. For http://www.google.com/search?q=devmo#test this is 80.

protocol

Data type string
Standard none
Documentation Mozilla Microsoft

The protocol of the URL. For http://www.google.com/search?q=devmo#test this is http:.

search

Data type string
Standard none
Documentation Mozilla Microsoft

The part of the URL that follows the ? symbol (i.e. query string), including the ? symbol. For http://www.google.com/search?q=devmo#test this is ?q=devmo.

Methods

assign

Data type function
Return type undefined
Parameter list url (string)
Standard none
Documentation Mozilla Microsoft

Load the document at the provided URL.

reload

Data type function
Return type undefined
Parameter list forceget (boolean)
Standard none
Documentation Mozilla Microsoft

Reload the document from the current URL. forceget is a boolean which, when it is true, causes the page to always be reloaded from the server. If it is false or not specified, the browser may reload the page from its cache.

replace

Data type function
Return type undefined
Parameter list url (string)
Standard none
Documentation Mozilla Microsoft

Replace the current document with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session history, meaning the user won't be able to use the Back button to navigate to it.

toString

Data type function
Return type string
Parameter list none
Standard none
Documentation Mozilla

Returns the location as seen in the location bar; primarily used to permit handling as an actual string, e.g. to call string-specific methods. While Microsoft supplies no documentation for this method, Mozilla's gives no mention of compatibility issues.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.