--- title: URL.hash slug: Web/API/URL/hash tags: - API - Hash - Propriété - Reference - URL translation_of: Web/API/URL/hash ---
La propriété hash
de l'interface {{domxref("URL")}} retourne un {{domxref("USVString")}} contenant le caractère '#'
suivi par l'identificateur de fragment de URL.
Le fragment n'est pas décodé en pourcent. Si l'URL ne contient pas d'identificateur de fragment, la valeur de cette propriété est une chaîne de caractère vide — ""
.
{{AvailableInWorkers}}
string = object.hash; object.hash = string;
Un {{domxref("USVString")}}.
var url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/href#Examples'); url.hash // Returns '#Examples'
Spécification | Statut | Commentaire |
---|---|---|
{{SpecName('URL', '#dom-url-hash', 'URL.hash')}} | {{Spec2('URL')}} | Définition initiale |
{{Compat("api.URL.hash")}}