Esempio
Ritorna il nome host della URL corrente:
var x = location.hostname;
Il risultato di x sarà:
Prova tu stesso " Definizione e utilizzo
Gli insiemi di proprietà hostname o restituisce il nome host di un URL.
Supporto per il browser
Proprietà | |||||
---|---|---|---|---|---|
hostname | sì | sì | sì | sì | sì |
Sintassi
Restituisce la proprietà hostname:
location.hostname
Impostare la proprietà hostname:
location.hostname= hostname
I valori delle proprietà
Value | Type | Description |
---|---|---|
hostname | String | Specifies the hostname of the URL |
Dettagli tecnici
Valore di ritorno: | Una stringa, che rappresenta il nome di dominio o l'indirizzo IP di un URL |
---|
