Auto refresh page and div using javascript?

File name : index.php

<html>
<head>
<meta http-equiv="refresh" content="5" />
<!-- This will refresh page in every 5 seconds, change content= x to refresh page after x seconds -->
<script type="text/javascript">
function autoRefresh()
{
window.location = window.location.href;
}
setInterval('autoRefresh()', 5000); // this will reload page after every 5 secounds; Method I
</script>
<script>
function autoRefresh1()
{
window.location.reload();
}
setInterval('autoRefresh1()', 5000); // this will reload page after every 5 secounds; Method II
</script>
</head>
<body>
<div id="result"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
function autoRefresh_div()
{
$("#result").load("load.html");// a function which will load data from other file after x seconds
}
setInterval('autoRefresh_div()', 5000); // refresh div after 5 secs
</script>
</body>
</html>

Reload OR Refresh page using javascript

File name : index.php

window.location.reload();

OR

window.location.href = window.location.href





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here