cambiar imagen a los 5 segundos

fitaka
24 de Marzo del 2006
驴c贸mo puedo cambiar la imagen de fondo a los 5 segundos por otra imagen distinta?

gracias de antemano.
saludos.

MC
24 de Marzo del 2006
C贸digo:

<SCRIPT LANGUAGE = "JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 5000 //milisegundos= segundo * 1000
var img=new Image();
img.src="direccion de la img";

function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 5
StopTheClock()
StartTheTimer()
}

function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}

function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
// aqui cambias la img
window.document.nombreimg.src="";
window.document.nombreimg.src="d://carpeta/nombre_img_nueva.jpg";

//y reinicias el contador
InitializeTimer();
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
//-->
</SCRIPT>

Este c贸digo que sigue lo metes dentro de la <body>:
onLoad="InitializeTimer()"


es decir:

<body onLoad="InitializeTimer()" >



fitaka
24 de Marzo del 2006
gracias por la "currada".
creo que tambien lo pued conseguir si pongo en la cabecera <metahttp-equiv="refresh"=numero de segundos;URL=nueva direccion"> es decir cargando primero una portada y a los 5 segundos el contenido con otra imagen de fondo.
lo provar茅 haber que tal.

saludos.