Source src Proprietà
Esempio
Restituisce l'URL di un file multimediale:
var x = document.getElementById("mySource").src;
Definizione e utilizzo
La proprietà src imposta o restituisce il valore dell'attributo src in un elemento <source>.
L'attributo src specifica l'URL del file multimediale da riprodurre.
Nota: Internet Explorer 8 e versioni precedenti restituisce solo il nome del file (ad es. horse.mp3), anziché l'URL (https://www.w3schools.com/jsref/horse.mp3).
Supporto del browser
Property | |||||
---|---|---|---|---|---|
src | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisce la proprietà src:
sourceObject.src
Imposta la proprietà src:
sourceObject.src = URL
Valori di proprietà
Value | Description |
---|---|
URL | Specifies the URL of the media file. Possible values:
|
Dettagli tecnici
Valore di ritorno: | Una stringa, che rappresenta l'URL del file multimediale. Restituisce l'intero URL, incluso il protocollo (come http://) |
---|
Pagine correlate
Riferimento HTML: attributo HTML <source> src
❮ Oggetto sorgente