troubleshooting Question

countdown without popup alert box

Avatar of yglobal
yglobal asked on
JavaScriptPHP
2 Comments2 Solutions1108 ViewsLast Modified:
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
Kin Fat SZE

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros