Image srcPropiedades
Objeto Image
Definición y uso
La propiedad src puede establecer o devolver el valor del atributo src de una imagen.
El atributo src especifica la URL de una imagen.
Sintaxis
imageObject.src=URL
Compatibilidad del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten el atributo src.
Ejemplo
Ejemplo
<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>
Pruébalo »
Objeto Image Otras extensiones