Location: toString()

The toString() stringifier method of the Location interface returns a USVString containing the whole URL. It is a read-only version of Location.href.


string = object.toString();


// Let's imagine an <a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/Location/toString"> element is in the document
var anchor = document.getElementById("myAnchor");
var result = anchor.toString(); // Returns: 'https://developer.mozilla.org/en-US/docs/Location/toString'


Specification Status Comment
HTML Living Standard Living Standard

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
toStringChrome Full support 52Edge Full support 12Firefox Full support 22IE Full support 11
Full support 11
Notes Intranet sites are set to Compatibility View, which will emulate IE7 and omit window.location.toString.
Opera ? Safari ? WebView Android Full support 52Chrome Android Full support 52Firefox Android Full support 22Opera Android ? Safari iOS ? Samsung Internet Android Full support 6.0


Full support  
Full support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.