Ok, so am new to JavaScript so i've been messing around with it a bit and just can not get it to pop up a box(make sure your not a bot) every umm say 10 minutes(since all you have to do is hit ok to continue). I do have a guild over javascript but it only goes over how to make it pop up when it is lets say 10pm, but what I want is it to pop up every 10 minutes not 10pm.

This is what it looks like for 10pm:

<script type="text/javascript">
//Write a "Good morning" greeting if
//the time is less than 10

var d=new Date();
var time=d.getHours();

if (time<10)
  {
  document.write("<b>Good morning</b>");
  }
</script>

Am not sure if what am doing wrong but I have tried changing the Hours to Minutes but didn't work.

This is what I have tried(i've also tried other ways):

<script type="text/javascript">
//Pops up an alert ever 10 minutes if
//its been 10 minutes since you last hit ok

var d=new Date();
var time=d.getMinutes();

if (time<10000)
  {
  alert("Hit ok to continue!");
  }
</script>

Thanks! I hope I have made this extremely clear if not sorry, am extremely tired )=

    You should use "setTimeout" to run a function

    Try this

    function popupbox() {
        alert("Hit ok to continue!");
    }
    
    setTimeout("popupbox()", 600000);
    

    I will note that everyone's computer ticks away those milliseconds at a slightly different rate so you may find that "600000" is a bit more or a bit less than 10 minutes.

      Write a Reply...