Proprietà window.location.hostname
- Pagina precedente host
- Pagina successiva href
- Torna alla pagina precedente Location window
Definizione e uso
location.hostname
Proprietà che restituisce l'host dell'URL (indirizzo IP o nome di dominio).
Puoi anche impostare location.hostname
Proprietà, naviga alla stessa URL con un nuovo nome di host.
Vedi anche:
Esempio
Restituire il nome dell'host dell'URL corrente:
let hostname = location.hostname;
Sintassi
Restituire l'attributo hostname:
location.hostname
Impostare l'attributo hostname:
location.hostname = hostname
Valore dell'attributo
Valore | Descrizione |
---|---|
hostname | Il nome dell'host dell'URL. |
Valore di ritorno
Tipo | Descrizione |
---|---|
Stringa | L'host dell'URL (indirizzo IP o nome di dominio). |
Supporto browser
Tutti i browser supportano location.hostname
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Supporto | Supporto | Supporto | Supporto | Supporto | Supporto |
- Pagina precedente host
- Pagina successiva href
- Torna alla pagina precedente Location window