Esempio
Restituisce il nome host di un link:
var x = document.getElementById("myAnchor").hostname;
Il risultato di x sarà:
www.example.com
Prova tu stesso " Definizione e l'utilizzo
Gli insiemi di proprietà hostname o restituisce la parte hostname del href valore di attributo.
Supporto browser
Proprietà | |||||
---|---|---|---|---|---|
hostname | sì | sì | sì | sì | sì |
Sintassi
Restituire la proprietà hostname:
anchorObject .hostname
Impostare la proprietà hostname:
anchorObject .hostname= I valori delle proprietà Valore Descrizione hostname Specifica il nome host di un URL
Dettagli tecnici
Valore di ritorno: A String, che rappresenta il nome di dominio (or IP address) del URL
Altri esempi
Esempio
Cambiare il nome host di un link:
document.getElementById("myAnchor").hostname = "www.somenewexamplepage.com"; Prova tu stesso "
Esempio
Un altro esempio di come cambiare il nome host di un collegamento:
document.getElementById("myAnchor").hostname = "www.w3ii.com"; Prova tu stesso "
Pagine correlate
Di riferimento JavaScript: location.hostname Property
<Oggetto Anchor