Link to home
Start Free TrialLog in
Avatar of yglobal
yglobal

asked on

countdown without popup alert box

I have pages that members look at for 5 seconds. If they do not look at them for that time and click to see the next one, they do not gain a point for viewing it.
I have a javascript that works fine for the countdown of the viewing time, but would like to remove the alert popup box that showws after 5 seconds, and just make it work silently behind the scenes as they already have one button to click to view the next and dont want to make them also click the alert box too. Can this be done?

<div id="iddate"></div>
 
<script type="text/javascript">
var clockSet = 0;
var viewTimeEnough = false;
 
function displayTime(delay){
  nowDate = new Date();
  if (clockSet != 1) {
 
    delayDate = new Date(nowDate.getTime() + delay*1000);
    clockSet = 1;
  }
 
  document.getElementById('iddate').innerHTML = Math.round((delayDate - nowDate)/1000) + ' Seconds';
  if (nowDate >= delayDate ) {
//    alert ('stop');
    viewTimeEnough = true;
    alert(viewTimeEnough);
    return;
  }
 
  setTimeout("displayTime();",1000);
 }
 
 
  displayTime(5);
 
 </script>
ASKER CERTIFIED SOLUTION
Avatar of Kin Fat SZE
Kin Fat SZE
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial