--- title: HTMLHyperlinkElementUtils.username slug: Web/API/HTMLAnchorElement/username tags: - HTMLHyperlinkElementUtils.username translation_of: Web/API/HTMLHyperlinkElementUtils/username original_slug: Web/API/HTMLHyperlinkElementUtils/username ---
{{ApiRef("URL API")}}
HTMLHyperlinkElementUtils.username
属性是一个 {{domxref("USVString")}}包含域名前面指定的用户名。
string = object.username; object.username = string;
// Let's <a id="myAnchor" href="https://anonymous:flabada@developer.mozilla.org/en-US/docs/HTMLHyperlinkElementUtils.username"> be in the document var anchor = document.getElementByID("myAnchor"); var result = anchor.username; // Returns:'anonymous'
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', '#dom-hyperlink-username', 'HTMLHyperlinkElementUtils.username')}} | {{Spec2('HTML WHATWG')}} | Initial definition. |