HTMLAnchorElement: toString() method

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

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

{{ApiRef("URL API")}}

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

Syntax

js-nolint
toString()

Parameters

None.

Return value

A string containing the element's complete URL.

Examples

Calling toString on an anchor element

js
// An <a id="myAnchor" href="/en-US/docs/HTMLAnchorElement"> element is in the document
const anchor = document.getElementById("myAnchor");
anchor.toString(); // returns 'https://developer.mozilla.org/en-US/docs/HTMLAnchorElement'

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • The {{domxref("HTMLAnchorElement")}} interface it belongs to.