Auto Refresh Webpage with PHP, HTML and JavaScript

I’m developing server checking & monitoring webpage. I would left the page open all the time on my browser. So it will be good to that page auto refresh every certain amount of time so I don’t have to keep hitting F5 manually to refresh.

There are a few option that I have, I can do it either by using PHP Code, HTML Meta tag or JavaScript.

For example I want to refresh the webpage every 10 seconds. The are the code.

PHP Code

<?php
   $url=$_SERVER['REQUEST_URI'];
   header("Refresh: 10; URL=$url");
?>

 

HTML Meta Tag

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

 

JavaScript

<body onload=”javascript:setTimeout(“location.reload(true);”,10000);”>


3 comments… add one
  • It is nicely working to auto refresh the page.
    i have a intranet. i am using date/time tag in this page.
    i have also a video continuously running in this page.

    I want a code just the date/time will be auto update. no effect on the video.

    Reply
  • Yeah…. thats good I’m gon over it

    Reply
  • For the JavaScript version getting work I had to enclose the location.reload(true) in a function

    Reply

Leave a Comment