Image srcPropriété
Objet Image
Définition et utilisation
La propriété src définit ou renvoie la valeur de l'attribut src d'une image.
L'attribut src spécifie l'URL d'une image.
Syntaxe
imageObject.src=URL
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge l'attribut src.
Exemple
Exemple
<html>
<head>
<script>
function changeSrc()
{
document.getElementById("myImage").src="hackanm.gif.html";
}
</script>
</head>
<body>
<img id="myImage" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSrc()" value="Change image">
</body>
</html>
<head>
<script>
function changeSrc()
{
document.getElementById("myImage").src="hackanm.gif.html";
}
</script>
</head>
<body>
<img id="myImage" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSrc()" value="Change image">
</body>
</html>
Essayez-le vous-même »
Objet Image Autres extensions