MathML
The hostname property of the MathMLAnchorElement interface is a string containing either the domain name or IP address of the <a> element's href. If the URL does not have a hostname, this property contains an empty string, "". IPv4 and IPv6 addresses are normalized, such as stripping leading zeros, and domain names are converted to IDN.
See URL.hostname for more information.
Value
A string.
Examples
Basic usage
Given this MathML:
<math>
<a id="myAnchor" href="https://example.com#examples"> ... </a>
</math>
you can get the hostname of the anchor like this:
const mathAnchor = document.getElementById("myAnchor");
mathAnchor.hostname; // returns 'example.com'
Specifications
Browser compatibility
See also
- The MathML
<a>element
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
