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
.
Syntax
string = object.toString();
Examples
// 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'
Specifications
Specification |
---|
HTML Standard # dom-location-href-dev |
Browser compatibility
BCD tables only load in the browser