Automatic redirection of pages

Asked

Viewed 44 times

0

I have 3 panels,example:

painel1.php

painel2.php

painel3.php

They’ll be playing on a monitor, which I would like:

That only one was opened on the screen, and that every 10 seconds the browser automatically changed to the other.

How could I make this process ?

  • It is more recommended to do javascript. Because PHP does not listen to time, it does not have this power, the PHP language is for writing pages. Javascript is for interaction.

  • The function can be quietly written in PHP by combining a loop with the Sleep function()

2 answers

2


You can do this with HTML meta tag, insert them into <head>:

With a time interval of 10 secs in each, in your case:

From painel1.php to painel2.php, enter the following meta tag in painel1.php:

<meta http-equiv="refresh" content="10;URL=painel2.php">

From painel2.php to painel3.php, enter the following meta tag in painel2.php:

<meta http-equiv="refresh" content="10;URL=painel3.php">

From panel 3.php back to panel 1.php, enter the following meta tag in panel 3.php:

<meta http-equiv="refresh" content="10;URL=painel1.php">

This will be on a loop

  • Perfect, thank you very much.

  • You’re welcome @Otáciobarbosa, nice to help

1

Since it will be exposed, better use a Javascript to put a transition effect, redirect are not aesthetically legal.

HTML

<div class="wrap"></div>        

CSS

* {padding:0;margin:0;}
.wrap {width:100%;height:100%;display:none;}

JS

$(document).ready(function(){ 

    //As páginas a serem carregadas devem estar na mesma pasta da sua aplicação
    url1 = 'money.php';
    url2 = "moneyMoney.php";
    url3 = "moneyMoneyMoney.php";
    atual = 2;

    $('.wrap').fadeIn(2000).load(url1);
    setInterval(trocar,15000);    

    function trocar(){
        $('.wrap').fadeOut(2000,function(){ 
            switch(atual){
                 case 1: 
                     $('.wrap').load(url1);
                     atual++; 
                 break;
                 case 2:
                     $('.wrap').load(url2);
                     atual++; 
                 break;
                 case 3: 
                     $('.wrap').load(url3);
                     atual = 1; 
                 break;
            }
            $('.wrap').fadeIn(2000); 
        });   
    }

});
  • I enjoyed it very much, Thank you. Ultilizei the of @miguel more also tested your,Thanks for the contribution.

Browser other questions tagged

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