--- title: HTMLHyperlinkElementUtils.pathname slug: Web/API/HTMLAnchorElement/pathname tags: - HTMLHyperlinkElementUtils.pathname translation_of: Web/API/HTMLHyperlinkElementUtils/pathname original_slug: Web/API/HTMLHyperlinkElementUtils/pathname ---
{{ApiRef("URL API")}}
HTMLHyperlinkElementUtils.pathname
属性是一个 {{domxref("USVString")}} ,其中包含一个初始的'/'后跟URL的路径。
string = object.pathname; object.pathname = string;
// Let's an <a id="myAnchor" href="https://developer.mozilla.org/en-US/docs/HTMLHyperlinkElementUtils.pathname"> element be in the document var anchor = document.getElementById("myAnchor"); var result = anchor.pathname; // Returns:'/en-US/docs/HTMLHyperlinkElementUtils.pathname'
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', '#dom-hyperlink-pathname', 'HTMLHyperlinkElementUtils.pathname')}} | {{Spec2('HTML WHATWG')}} | Initial definition. |