This is sort of the reverse of what you asked but will function the same basically. Rather than counting how long a window is open it counts down from a specific time interval.
Copy and paste this into the body of your page.
Code:
<script language="JavaScript" type="text/javascript">
//Set the time to wait in seconds
var countDownInterval=5;
var countDownTime=countDownInterval+1;
function countDown(){
countDownTime--;
if (countDownTime <=0){
countDownTime=countDownInterval;
clearTimeout(counter)
//Set the page to go to
window.location = 'page2.htm'
return
}
if (document.all) //if IE 4+
document.all.countDownText.innerText = countDownTime+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText").innerHTML=countDownTime+" "
else if (document.layers){
//CHANGE TEXT BELOW TO YOUR OWN
document.c_reload.document.c_reload2.document.write('Redirect in <strong id="countDownText">'+countDownTime+' </strong> seconds')
document.c_reload.document.c_reload2.document.close()
}
counter=setTimeout("countDown()", 1000);
}
function startit(){
if (document.all||document.getElementById)
//CHANGE TEXT BELOW TO YOUR OWN
document.write('Redirect in <strong id="countDownText">'+countDownTime+' </strong> seconds')
countDown()
}
if (document.all||document.getElementById)
startit()
else
window.onload=startit
</script>