Do not redirect in Firefox [closed]

-1

The following code is not working in Firefox.

 <script>
         function go(){
           document.write('<p align="center">AGUARDE O ENCERRAMENTO...</p>');
         } 
         setInterval("go();", 3000);
         setInterval(function () { location.href = 'sair.php'; }, 5000);
</script>
    
asked by anonymous 26.01.2016 / 13:40

2 answers

3

Your code seems to have some errors, or rather, it would not be the best way to do it.

setInterval will generate a repeat over a given interval. If you want to delay redirection, use setTimeout , which counts a time and then performs the function at the end of that time, but only once.

function go()
{
   document.write('<p align="center">AGUARDE O ENCERRAMENTO...</p>');
   setTimeout(function () { 
     location.href = '/sair.php'; 
   }, 5000);
} 


go();
    
26.01.2016 / 13:47
-3

When you use setInterval or setTimeout, the way you perform a function is different, the quotes in her call do not exist, as well as the parentheses.

So:

function go(){
    document.write('AGUARDE O ENCERRAMENTO...');
}

setInterval(go, 3000);
setInterval(function(){
    location.href = 'sair.php'; 
}, 5000);
    
26.01.2016 / 13:48