Location: toString() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{ApiRef("Location")}}

The **toString()** {{Glossary("stringifier")}} method of the {{domxref("Location")}} interface returns a string containing the whole URL, which is the same value as {{domxref("Location.href")}}.

Syntax

js-nolint
toString()

Parameters

None.

Return value

A string representing the object's URL.

Examples

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'

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}