Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refresh WebPage periodically

My requirement is that i have a .php page that has to display some graphs/data based on data from a database. I would like refresh the page automatically and periodically so that graphs/data can be updated, as the data is obtained only on loading of the page. How can i do this ?

like image 553
Cygnus Avatar asked Jun 08 '12 06:06

Cygnus


People also ask

Can I make Chrome Refresh page automatically?

Click on the puzzle piece icon, then on “Easy Auto Refresh”. In the popup window, enter the number of seconds after which you want the page to refresh, then click “Start”. The page will automatically refresh every time the timer you set expires.

How do I refresh a web page every 30 seconds?

If you really want to do it with JavaScript, then you can refresh the page every 30 seconds with Location. reload() (docs) inside a setTimeout() : window. setTimeout( function() { window.

How do I make HTML refresh automatically?

Approach 1: One can auto refresh the webpage using the meta tag within the head element of your HTML using the http-equiv property. It is an inbuilt property with HTML 5. One can further add the time period of the refresh using the content attribute within the Meta tag.


2 Answers

Maybe you can try the setTimeout javascript method

setTimeout("location.reload(true);",timeoutPeriod);

this would refresh the page on every timeoutPeriod interval.

like image 73
KiiroSora09 Avatar answered Dec 10 '22 21:12

KiiroSora09


You can use javascript.

JS function

function timedRefresh(timeoutPeriod) {
    setTimeout("location.reload(true);",timeoutPeriod);
}

Add below line on body tag.

 <body onload="JavaScript:timedRefresh(5000);"> // time : 5000= 5 secs
like image 28
Alpesh Prajapati Avatar answered Dec 10 '22 20:12

Alpesh Prajapati