# Javascript: dont refresh if timer \> 0

**URL:** <https://forum.kirupa.com/t/javascript-dont-refresh-if-timer-0/168403>\
**Category:** Uncategorized\
**Created:** [November 7, 2005, 12:15am UTC](https://forum.kirupa.com/t/javascript-dont-refresh-if-timer-0/168403 "2005-11-07T00:15:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dinkumrocks](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dinkumrocks](https://forum.kirupa.com/u/dinkumrocks)\
**Post date:** [November 7, 2005, 12:15am UTC](https://forum.kirupa.com/t/javascript-dont-refresh-if-timer-0/168403/1 "2005-11-07T00:15:27Z")

</div>

Hey. This is my problem. I have a timer on my site till te page redirects. What I want to do is have it so that you can’t refresh unless the timer has reached zero. I put the code for the timer below too if that does anything.

\<script language=“JavaScript” type=“text/javascript”\>  
var Counter = “15”;  
var AFTER\_URL = “\<?php echo $rnd\_site;?\>”;  
var TIME=1\*1000;  
var TIMER = null;  
var boolRole = null;  
parent.ok=0;

function stop()  
{  
if(TIMER)  
{  
clearInterval(TIMER);  
TIMER=null;  
boolRole = false;  
}  
}  
function pause()  
{  
if(boolRole == true){  
boolRole = false;  
}else{  
boolRole = true;  
};  
click();  
};  
function start()  
{  
stop();  
boolRole = true;  
TIMER=setInterval(“click()”,TIME);  
}  
function click()  
{  
if(boolRole)  
{  
if ((document.getElementById(‘timer’).innerHTML="Seconds remaining: "+Counter–)\<0)  
{  
stop();  
}  
if (!Counter)  
{  
parent.display.location.href=AFTER\_URL;  
document.location=“earn\_top.php”;  
}  
}  
};  
function initThis()  
{  
start();  
boolRole = true;  
}  
\</script\>

thanks for any help,  
-Naaman
