Код:
<span id="counter"></span>
<SCRIPT LANGUAGE = "JavaScript">
var secs
var timerID = null
var timerRunning = false
var delay = 1000
InitializeTimer()
function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 15
StopTheClock()
StartTheTimer()
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
window.location.href = "http://сайт.ру"
}
else
{
document.getElementById("counter").innerHTML = "Через " + secs + " сек страничка откроется"
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
</SCRIPT>
Работает в теле HTML страницы