<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Recargar Imagen Cada 5 Segundos</title>
</head>
<body>
<img id="imagen" src="" alt="Imagen" width="128" height="" />
<script type="text/javascript">
function recargar_imagen() {
/* Un elemento por imagen de fondo deseado */
var fondos = [
"http://www.macuarium.com/actual/img/2004/02/08_osxicons_6/home.jpg",
"http://iconos.gratis.es/iconos/avatares-personas/armadura_avatar.png",
"http://1.bp.blogspot.com/-xK2IJjw4_Qk/UDovPLPNbgI/AAAAAAAAByg/yGCo9mkbuDA/s1600/IconoCorazonAmoYouTube.png",
"http://4.bp.blogspot.com/_hljKDuw-cxQ/S3ojYzz4J-I/AAAAAAAAPIw/NbZMlREVdc0/s00/5kitty_icons.png"
];
/* Cambio de imagen de fondo asegurando que no se repetirá el anterior */
do {
indice = Math.floor(Math.random() * fondos.length);
} while (fondos.length > 0 && indice == anterior);
anterior = indice;
/* Cambio efectivo de la imagen de fondo */
imagen.src = fondos[indice];
}
/* Cambiamos el fondo de pantalla cuando todo haya sido descargado */
var indice, anterior = -1;
window.onload = function(){
var imagen = document.getElementById("imagen");
recargar_imagen();
};
// Establecemos el temporizador a 5 segundos
timer = setInterval("recargar_imagen()", 5000);
</script>
</body>
</html>