Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1238 Using JavaScript how can I force the browser to reload the current page every second from the server?

You are here: irt.org | FAQ | JavaScript | Misc | Q1238 [ previous next ]

If the following is saved as test.htm then it'll reload itself every second.

Watch the URL bar!

<html>
<head>
<script language="JavaScript"><!--
function reloadFunction() {
    // assuming url of:  test.htm - eanables me to test
    // may need to parse location.href if the url is not fixed
    location.href = 'test.htm' + '?' + ((new Date()).getTime());
}
//--></script>
</head>

<body onLoad="setTimeout('reloadFunction()',1000)"> <!-- invoke reload after 1 sec -->

<body>
</html>

©2018 Martin Webb