HTMLAnchorElement:username 属性

HTMLAnchorElement.username 属性是一个字符串,包含在域名之前指定的用户名。

一个字符串。

示例

从锚点链接中获取用户名

js
// 假设文档中含有这样的元素:<a id="myAnchor" href="https://anonymous:flabada@developer.mozilla.org/zh-CN/docs/HTMLAnchorElement">
const anchor = document.getElementByID("myAnchor");
anchor.username; // 返回 'anonymous'

规范

Specification
HTML Standard
# dom-hyperlink-username-dev

浏览器兼容性

BCD tables only load in the browser

参见