Attributo hostname dell'anchor
Definizione e uso
hostname
Impostazione o restituzione dell'attributo Valore dell'attributo href la parte del nome del dominio.
Vedi anche:
Manuale JavaScript:Attributo location.hostname
Esempio
Esempio 1
Restituisce il nome del dominio del link:
var x = document.getElementById("myAnchor").hostname;
Esempio 2
Modifica il nome del dominio del link:
document.getElementById("myAnchor").hostname = "www.somenewexamplepage.com";
Esempio 3
Un altro esempio su come modificare il nome del dominio del link:
document.getElementById("myAnchor").hostname = "www.codew3c.com";
Sintassi
Restituisce l'attributo hostname:
anchorObject.hostname
Imposta l'attributo hostname:
anchorObject.hostname = hostname
Valore dell'attributo
Valore | Descrizione |
---|---|
hostname | Specificare il nome dell'host dell'URL. |
Dettagli tecnici
Valore di ritorno: | Valore di stringa, rappresenta il dominio dell'URL (o l'indirizzo IP). |
---|
Supporto browser
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supporto | Supporto | Supporto | Supporto | Supporto |