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="/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

BCD tables only load in the browser