This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

window.location.href

Summary

The full url for this resource. Synonymous with String(window.location).

Property of apis/locationapis/location

Syntax

Note: This property is read-only.

var result = window.location.href;

Return Value

Returns an object of type StringString

The full url for this resource.

For example, http://example.org/index.html?page=1#foo would return the full href of http://example.org/index.html?page=1#foo.

Examples

window.location.href is the same as the toString method of window.location, so you can choose to use either variable when using comparing as a string.

if(window.location == window.location.href){
    // This equates to true
    alert("These values are the same.")/
}

Related specifications

Window Object 1.0
W3C Working Draft