Refreshing page in Javascript

In this article we will see that how to refresh or reload a page through Java Script there are a lot of ways to refresh or reload a document depending how we want (from server side
,get request, post request or from browser cache) some of the ways is given bellow.

  • To Refreshing page through Get request

<input type="button" value="Reload Page"
onClick="window.location.href=window.location.href">

  • To Refreshing page through last request (Get or Post)

<input type="button" value="Reload Page" onClick="window.location.reload()">

  • To reload page through browser cache 

<input type="button" value="Reload Page" onClick="history.go(0)">

  • To Refreshing Periodically

function refreshPeriodic()
{
location.reload();
timerID=setTimeout("refreshPeriodic()",30000);
}
timerID=setTimeout("refreshPeriodic()",30000);


  • Reloading page through Meta Tag automatically after 10 seconds.

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


Popular Posts