Mar 31, 2012

HTTP META tag Auto Refresh Loop

How to Auto Refresh using META tag


One can add auto refresh feature in web applications in multiple ways which include HTTP Meta tag and JavaScript reload() function. Both methods can cause the page to auto refresh in a loop and execute the page refresh event after a specific period of time.

HTTP Meta tag auto refresh


The following code if present in the html page then it will cause the page to get auto refresh after every 10 seconds. If you want to use this HTTP response header then you need to add it to your HTML page's HEAD tag. One can also include this META tag in all pages if you want to auto refresh all page of the web applications.

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

It is a good idea to show a count down timer so that users know when the page will get refreshed.

Another version of META tag shown above is:

<meta http-equiv="refresh" content="10" url="http://abc123.com">

The above version will automatically redirect the page to abc123.com after waiting for 10 seconds.
It is worth mentioning here that the count down timer for meta tag starts after the page has been loaded by browser and DOM structure is ready.

No comments:

Post a Comment