How to print an X message in X minutes with Javascript

Asked

Viewed 182 times

1

I need to print a message every five minutes:

alert("que venham mais 5 minutos");

How do I?

  • 6

    Do you want to create a dynamic page that writes "5 minutes more" every 5 min? If it is, it should be done with Javascript, not PHP.

  • Lucas Nunes, depending on the purpose... some situations require some server side validation... there is no way.. But it may be that his case can be solved client-side. I would mark this issue as ambiguous, incomplete, etc.. lacks more information.

  • What exactly do you want to do ?

  • If you are on the server side you can use a cron.

1 answer

4


I advise you to do this in Javascript. It would be something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery timer - Codigos Fontes</title>

<script type="text/javascript" src="js/jquery-1.9.1.min.js" ></script>
<script type="text/javascript">
    $(window).load(function() {
        setInterval( function(){

            alert('Que venham mais 5 minutos');

        }, 50000);
    });
</script>

</head>

    <body>
        <h1>Utilizando jQuery com timer: setInterval</h1>
        <p>Aguarde 5 minutos...</p>
    </body>

</html>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.