Posizione della finestra.nomehost
Esempio
Restituisce il nome host dell'URL corrente:
let hostname = location.hostname;
Definizione e utilizzo
La location.hostname
proprietà restituisce l'host (indirizzo IP o dominio) di un URL.
La location.hostname
proprietà può anche essere impostata per navigare allo stesso URL con un nuovo nome host.
Sintassi
Restituisce la proprietà del nome host:
location.hostname
Imposta la proprietà del nome host:
location.hostname = hostname
Valore della proprietà
Value | Description |
hostname | The hostname of the URL. |
Valore di ritorno
Tipo | Descrizione |
Una stringa | L'host (indirizzo IP o dominio) di un URL. |
Supporto browser
location.hostname
è supportato in tutti i browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |