The toString()
stringifier method of the Location
interface returns a string containing the whole URL. It is a read-only version of Location.href
.
The toString()
stringifier method of the Location
interface returns a string containing the whole URL. It is a read-only version of Location.href
.
js
toString()
None.
A string representing the object's URL.
js
// Let's imagine this code is executed on https://example.com/path?search#hash const result = window.location.toString(); // Returns: 'https://example.com/path?search#hash'
Specification |
---|
HTML Standard # dom-location-href-dev |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
toString |
52 | 12 | 22 | 11Intranet sites are set to Compatibility View, which will emulate IE7 and omitwindow.location.toString . |
39 | 1 | 52 | 52 | 22 | 41 | 1 | 6.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Location/toString