English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Attribut pathname de Location

Objet Location

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.

Syntaxe :

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‹/›

Compatibilité du navigateur

Tous les navigateurs prennent en charge pleinement l'attribut pathname :

Attribut
pathnameEstEstEstEstEst

Valeur de l'attribut

ValeurDescription
pathChaîne, spécifiant le chemin d'URL

Détails techniques

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

Plus d'exemples

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érences associées

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

Objet Location