Javascript to reload a web page

I recently had a little problem to solve: I want to update (very) quickly the display of a web page. For this kind of job, there is usually the easy solution to write the command in the headers of the HTML page using the META REFRESH tag, but this is acceptable only if you meet two important conditions siimultaneously (in most cases, this is no problem indeed):

  • get a free access to the server generating the web page you want to display, in order to modify its HTML code,
  • accept a maximum update frequency of one second (this is normally more than enough if you are working on the Internet, but I am working with HTML technology on a local application for a non-networked PC).

Not able to meet those pre-conditions, I went searching for my own solution to the problem. My first ideas were:

  • Use Opera (it includes an auto-reload feature on a page-by-page or tab-by-tab basis); But the highest reload frequency is still one second.
  • Use the ReloadEvery plug-in for Firefox; But it has the same constraints.

In both cases, I did not have access to the source code to apply modifications that would probably have turned to be merely trivial. I should find another solution and I turned to Javacript code.

It consisted in writing a little Javascript code snipet that I would integrate into an HTML page to request a fast reload (every 200 milliseconds) of the interesting web page.

In order to share that little knowledge I acquired, here is the code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.