Web Designers needing to have a particular page to auto-reload, can easily accomplish such task just by adding a meta tag within the head section.
A web page containing dynamic content (weather, news, etc.) can change periodically. Refreshing the page ensures that users can see the most recent information.
Place a meta tag within the head section,
set the http-equiv attribute to a value of refresh,
then set the content attribute to the number of seconds you want the web page to automatically refresh.
Place the following meta tag within the head section of your page:
<meta http-equiv=”refresh” content=”120″>
<html>
<head>
<title> My Auto Refresh Page</title>
<meta http-equiv=”refresh” content=”120″>
</head>
<body>
This is my auto-refresh page…
</body>
</html>
If you want to refresh the page only if there is no activity, let’s refresh it every minute unless someone presses a key or moves the mouse.
<script>
var time = new Date().getTime();
$(document.body).bind(“mousemove keypress”, function(e) {
time = new Date().getTime();
});
function refresh() {
if(new Date().getTime() – time >= 60000)
window.location.reload(true);
else
setTimeout(refresh, 10000);
}
setTimeout(refresh, 10000);
</script>