0

I need do a automatic foward/redirect.

If the user dont click anywhere in the site five seconds after automatic foward to homepage... it is possible?

For example,

<meta http-equiv="Refresh" content="5;URL=http://www.teste.com/sv1/index.html">

Thanks

kelunik
  • 6,750
  • 2
  • 41
  • 70
Ricardo
  • 37
  • 1
  • 7
  • 1
    You need to learn where PHP starts and stops in the page request pricess – John Conde Oct 16 '13 at 15:14
  • 1
    In what respect does your example fail to do what you want? – Oswald Oct 16 '13 at 15:14
  • [take a look at this page](http://stackoverflow.com/questions/3253223/redirect-in-php?rq=1)... I think it might be the same question. I would personally use jquery for this, though, [like this](http://stackoverflow.com/questions/7276677/jquery-redirect-to-url-after-specified-time) or [this with an "abort" option](http://stackoverflow.com/questions/3234017/jquery-redirect-on-click-or-after-10-seconds/3234034#3234034) – gloomy.penguin Oct 16 '13 at 15:14
  • PHP is an server side scripting language it can not do what you desire here. –  Oct 16 '13 at 15:55

3 Answers3

3

try this in your head:

<script type="text/javascript">
var redirect = setTimeout(function() {
    window.location = "http://stackoverflow.com";
}, 5000);

document.onclick = function() {
    clearTimeout(redirect);
}
</script>
kelunik
  • 6,750
  • 2
  • 41
  • 70
0

In PHP it's not possible. You can add timeout in JS and stop it when user click somewhere (onclick event on body).

After that timeout (without clicks), yuo can redirect user by setting document.location.href to your homepage.

Elon Than
  • 9,603
  • 4
  • 27
  • 37
0

Short: No.

Longer: This is not possible with PHP, because PHP is precompiled on the server. So as soon as the user sees the page on his browser, the PHP script already ran through. You will have to use something else instead, for example JavaScript.

Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116