¿Como hago para que una imagen se cambie por otra al pasar el mouse sobre ella?
...Espero que haya quedado clara mi pregunta. Lo que quiero hacer es poner una imagen con un link pero que la imagen se cambie por otra imagen cuando el mouse este sobre ella. SÃ me entendieron ¡Ayudenme por favor!
Hola, mirá tenés que copiar este código entre las etiquetas <head> y </head>
<SCRIPT LANGUAGE="Javascript">
<!-- Consigue mas JavaScript en http://www.mundojavascript.com -->
<!-- Swap images
function Permut (flag,img) {
if (document.images) {
if (document.images[img].permloaded) {
if (flag==1) document.images[img].src = document.images[img].perm.src
else document.images[img].src = document.images[img].perm.oldsrc
}
}
}
function preloadPermut (img,adresse) {
if (document.images) {
img.onload = null;
img.perm = new Image ();
img.perm.oldsrc = img.src;
img.perm.src = adresse;
img.permloaded = true;
}
}
// -->
</SCRIPT>
Y donde vá la imagen (<body>)
<A HREF="intercambio.html" TARGET="_BLANK" onMouseover="Permut(1,'IMG1');" onMouseout="Permut(0,'IMG1');">
<IMG SRC="imagen2.gif" border=0 NAME="IMG1" onLoad="preloadPermut(this,'imagen3.gif');" ></A>
Si tenés que poner más de una imagen cambiale el número de la IMG1, IMG2 ... (en todas las etiquetas)
<SCRIPT LANGUAGE="Javascript">
<!-- Consigue mas JavaScript en http://www.mundojavascript.com -->
<!-- Swap images
function Permut (flag,img) {
if (document.images) {
if (document.images[img].permloaded) {
if (flag==1) document.images[img].src = document.images[img].perm.src
else document.images[img].src = document.images[img].perm.oldsrc
}
}
}
function preloadPermut (img,adresse) {
if (document.images) {
img.onload = null;
img.perm = new Image ();
img.perm.oldsrc = img.src;
img.perm.src = adresse;
img.permloaded = true;
}
}
// -->
</SCRIPT>
Y donde vá la imagen (<body>)
<A HREF="intercambio.html" TARGET="_BLANK" onMouseover="Permut(1,'IMG1');" onMouseout="Permut(0,'IMG1');">
<IMG SRC="imagen2.gif" border=0 NAME="IMG1" onLoad="preloadPermut(this,'imagen3.gif');" ></A>
Si tenés que poner más de una imagen cambiale el número de la IMG1, IMG2 ... (en todas las etiquetas)