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>
JavaScriptPHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Kin Fat SZE

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes