JavaScript Code to Refresh page in Fixed Interval
In many cases we need to Create a JavaScript function to refresh webpage in periodic intervals for applications like market status, weather reports and some applications which changes time to time we need to reload a page or particular area in a webpage. Here there are two examples for refreshing webpage with fixed time interval.
//Example 1 calling JavaScript in onload()
<html><head>
<script type="text/javascript">
function refreshpage(){
setTimeout("refresh()", 2000);
}
function refresh(){
window.location.reload();
load();
}
</script>
</head>
<body onload="refreshpage()">
</body>
</html>
//Example 2 calling by default
<script>
var timer;
function refreshmypage(){
document.location=document.location.href;
}
timer=setTimeout(refreshmypage,60*1000);
</script>
