MathMLAnchorElement
MathML
MathML
The MathMLAnchorElement interface represents MathML <a> (hyperlink) elements and provides properties for getting and setting various features of such elements.
Instance properties
Inherits properties from its parent, MathMLElement.
- MathMLAnchorElement.download
- : A string indicating that the linked resource is intended to be downloaded rather than displayed in the browser.
- MathMLAnchorElement.hash
- : A string representing the fragment identifier, including the leading hash mark (
#), if any, in the referenced URL. - MathMLAnchorElement.host
- : A string representing the hostname and port (if it's not the default port) in the referenced URL.
- MathMLAnchorElement.hostname
- : A string representing the hostname in the referenced URL.
- MathMLAnchorElement.href
- : A string that is the result of parsing the element's
hrefattribute relative to the document, containing a valid URL of a linked resource. - MathMLAnchorElement.hreflang
- : A string that reflects the element's
hreflangattribute, indicating the language of the linked resource. - MathMLAnchorElement.origin
- : Returns a string containing the origin of the URL, that is its scheme, its domain and its port.
- MathMLAnchorElement.password
- : A string containing the password specified before the domain name.
- MathMLAnchorElement.pathname
- : A string containing an initial
/followed by the path of the URL, not including the query string or fragment. - MathMLAnchorElement.ping
- : A space-separated list of URLs. When the link is followed, the browser will send POST requests with the body
PINGto the URLs. - MathMLAnchorElement.port
- : A string representing the port component, if any, of the referenced URL.
- MathMLAnchorElement.protocol
- : A string representing the protocol component, including trailing colon (
:), of the referenced URL. - MathMLAnchorElement.referrerPolicy
- : A string defining how much of the referrer to send when following the link, and under what circumstances.
- MathMLAnchorElement.rel
- : A space-separated list of link types indicating the relationship between the resource represented by the link and the current document.
- MathMLAnchorElement.relList
- : A live DOMTokenList object containing the set of link types indicating the relationship between the resource represented by the link and the current document.
- MathMLAnchorElement.search
- : A string representing the search element, including leading question mark (
?), if any, of the referenced URL. - MathMLAnchorElement.target
- : A string that reflects the element's
targetattribute, indicating where to display the linked resource. - MathMLAnchorElement.type
- : A string that reflects the element's
typeattribute, indicating the MIME type of the linked resource. - MathMLAnchorElement.username
- : A string containing the username specified before the domain name.
Examples
Basic usage
This example marks up the Gamma function in MathML. It demonstrates how to access MathML <a> properties in JavaScript via the MathMLAnchorElement interface.
MathML
The example includes several <a> elements. The first one is an example.com link that includes several link and URL features that we can target with JavaScript. We also include a ul element to output property values to.
```html live-sample___mathmlanchorelement
```css hidden live-sample___mathmlanchorelement
math {
font-size: 4vw;
}
JavaScript
We get references to the first MathML <a> element in the document and the <ul> element.
```js live-sample___mathmlanchorelement const mathAnchor = document.querySelector("math a"); const list = document.querySelector("ul");
Next, we define a function that takes a string value representing a property of the `MathMLAnchorElement` object and appends an li to the `list` containing the property name and property value:
```js live-sample___mathmlanchorelement
function outputValue(value) {
const listItem = document.createElement("li");
listItem.textContent = `${value}: ${mathAnchor[value]}`;
list.appendChild(listItem);
}
Finally, we call the function several times to output names and values of properties defined directly on the interface to the list:
js live-sample___mathmlanchorelement
outputValue("href");
outputValue("target");
outputValue("origin");
outputValue("protocol");
outputValue("username");
outputValue("password");
outputValue("host");
outputValue("hostname");
outputValue("port");
outputValue("pathname");
outputValue("search");
outputValue("hash");
outputValue("hreflang");
outputValue("type");
Result
100%
Specifications
Browser compatibility
See also
- The MathML
<a>element