Attributo href del link
Definizione e uso
href
Imposta o restituisce l'URL del documento collegato.
Vedi anche:
Manuale HTML:Proprietà href dell'etichetta <link> HTML
Manuale HTML:Etichetta <link> HTML
Esempio
Esempio 1
Restituisce l'URL del documento collegato:
var x = document.getElementById("myLink").href;
Esempio 2
Cambia la tabella di stili:
document.getElementById("myLink").href = "style2.css";
Sintassi
Restituisce l'attributo href:
linkObject.href
Imposta l'attributo href:
linkObject.href = URL
Valore dell'attributo
Valore | Descrizione |
---|---|
URL |
Determina l'URL del risorsa/documento collegato. Valori possibili:
|
Dettagli tecnici
Valore di ritorno: | Valore di stringa che rappresenta l'URL del documento collegato. Restituisce l'intero URL, inclusi il protocollo (ad esempio http://). |
---|
Supporto browser
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Supporto | Supporto | Supporto | Supporto | Supporto |