Refresh page automatically

I will create a jQuery slide show, but you need to refresh the page every 5 minutes to change the content.

I know that I can do this with Javascript, but this can be changed on the client side to avoid page refresh. Is there a way for the server to drag out the page and force refresh?

+5
source share
7 answers

In addition to reloading javascript, you can send the update header:

header("Refresh: 300;url='http://thepage.com/example'");

The browser will be redirected after 300 seconds regardless of javascript. However, it can be disabled in the browser configuration, but it usually does not turn off.

+19
source

Updating the meta will work very simply:

<meta http-equiv="refresh" content="300">

300 , 300 5 . , JavaScript, .

+14

.

JavaScript :

setTimeout(function() {
    window.location.reload();
}, 5000);

, reguler script.


: - , ?

+4

META Tag

The following refreshes the page every 30 seconds.

<head>
<meta http-equiv="refresh" content="30" />
</head>
+1

PHP

php-, url

    // write the function
    function refresh( $time ){
        $current_url = $_SERVER[ 'REQUEST_URI' ];
        return header( "Refresh: " . $time . "; URL=$current_url" );
    }

    // call the function in the appropriate place
    refresh( 4 );   
    // this refreshes page after 4 seconds
+1

JavaScript

var timer = null;

function auto_reload()
{
  window.location = 'http://domain.com/page.php';
}

<body onload="timer = setTimeout('auto_reload()',10000);">
0

- window.location:

    setTimeout(function(){
        window.location.href = "YOUR_PAGE_URL";
    }, 5000);
-1

All Articles