Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/07/2008, 03:02
Avatar de Raulmmmm
Raulmmmm
 
Fecha de Ingreso: marzo-2007
Ubicación: En otro lugar que tú
Mensajes: 1.549
Antigüedad: 17 años, 1 mes
Puntos: 36
Respuesta: Imagen de fondo en sitio web

Aquí tienes el código:
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cambio de fondos con Javascript</title>
<script type="text/javascript">
var fondo = new Array();
fondo[0] = 'url(1.jpg)';
fondo[1] = 'url(2.jpg)';
fondo[2] = 'url(3.jpg)';
function cambiarfondo(seleccion){
document.body.style.background = fondo[seleccion];
}
</script>

</head>
<body>
<button onfocus="cambiarfondo(0)">Primer fondo</button> 
<button onfocus="cambiarfondo(1)">Segundo fondo</button> 
<button onfocus="cambiarfondo(2)">Tercer fondo</button> 
</body>
</html> 
Simplemente tienes que cambiar 1.jpg, 2.jpg y 3.jpg (van después de <script type="text/javascript">) por la ruta de las imágenes que quieras.