Collega proprietà href
Esempio
Restituisci l'URL del documento collegato:
var x = document.getElementById("myLink").href;
Definizione e utilizzo
La proprietà href imposta o restituisce l'URL di un documento collegato.
Supporto browser
Property | |||||
---|---|---|---|---|---|
href | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisci la proprietà href:
linkObject.href
Imposta la proprietà href:
linkObject.href = URL
Valori di proprietà
Value | Description |
---|---|
URL |
Specifies the URL of the linked resource/document Possible values:
|
Dettagli tecnici
Valore di ritorno: | Una stringa, che rappresenta l'URL del documento collegato. Restituisce l'intero URL, incluso il protocollo (come http://) |
---|
Altri esempi
Esempio
Cambia foglio di stile:
document.getElementById("myLink").href = "style2.css";
Pagine correlate
Riferimento HTML: attributo HTML <link> href
❮ Collega oggetto