English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
pathnameDéfinir ou retourner un nom de chemin d'URL.
Le nom de chemin est une chaîne qui commence par le nom d'hôte, et contient un "initial/”, suivi du chemin d'URL.
Retourner l'attribut de nom de chemin :
location.pathname
Définir l'attribut de nom de chemin :
location.pathname = path
var x = location.pathname; document.querySelector("#output").innerHTML = x;Vérifiez ici‹/›
Tous les navigateurs prennent en charge pleinement l'attribut pathname :
Attribut | |||||
pathname | Est | Est | Est | Est | Est |
Valeur | Description |
---|---|
path | Chaîne, spécifiant le chemin d'URL |
Valeur de retour : | Chaîne, représentant le chemin d'URL ; si il n'y a pas de chemin, il est une chaîne vide |
---|
Ce exemple montre toutes les propriétés de position :
var txt = ""; txt += "<p>Hôte: " + location.host + "</p>"; txt += "<p>Nom d'hôte: " + location.hostname + "</p>"; txt += "<p>Href: " + location.href + "</p>"; txt += "<p>Origine: " + location.origin + "</p>"; txt += "<p>Chemin: " + location.pathname + "</p>"; txt += "<p>Protocole: " + location.protocol + "</p>"; txt += "<p>Recherche: " + location.search + "</p>"; document.write(txt);Vérifiez ici‹/›
Référence de position :Propriété location.href
Référence de position :Propriété location.host
Référence de position :Propriété location.origin
Référence de position :Propriété location.protocol