JavaScript Refresh Page with Specific Times Example

How to auto refresh page using JavaScript, Here are JavaScript confirm box, when its confirm after page refresh automatically.

Example

<html>
<head>
    <title>JavaScript refresh page</title>
</head>
<body>
    <a href="javascript:location.reload(true);">Refresh this page</a>
</body>
</html>

Example Result

After 5 seconds page refresh

Example

<html>
<head>
    <title>JavaScript page refresh example</title>
    <script type="text/JavaScript">
        function timeRefresh(timeoutPeriod) {
            setTimeout("location.reload(true);", timeoutPeriod);
        }
    </script>
</head>
<body onLoad="JavaScript:timeRefresh(5000);">
  <h3>This page will auto refresh after 5 seconds.</h3>
</body>
</html>

Run it...   »

Example Result

User confirm after 5 seconds page refresh

Example

<html>
<head>
    <title>JavaScript page refresh example</title>
    <script language="javascript" type="text/javascript">
        function confirm_refresh() {
            var Refresh = confirm("Do you want to refresh the page?");
            if (Refresh) {
                setTimeout("location.reload(true);", 5000);
            }
        }
    </script>
</head>
<body>
    <p>Click Here: <a href="javascript:confirm_refresh();">Refresh this page after 5 seconds.</a></p>
</body>
</html>

Run it...   »

Example Result