Auto Refreshing Iframes

Oct 14th, 2008 | By sguler | Category: Javascript

Quoted from Wikipedia, “IFrame (from Inline Frame) is an HTML element which makes it possible to embed an HTML document inside another HTML document”.

If you are using iframes to serve frequently updated feeds on your site, such as a score board, news feed, then you should provide your visitors an iframe updating automaticaly while the page stays same. This is accomplished by a javascript function. You can easily set a time interval to refresh a specific iframe on your page by this way. As a result, your users don’t have to refresh the whole page every time to update the feed flow.

Put the following function inside head tags on your page.


Also put an onload attribute for the body tag, similar to the following:


Finally, don’t forget to name your iframe as it is called in javascript function (”iframename” in this example).

An example using this function is a football live scores page.

  • Share/Save/Bookmark
Tags: , ,

One comment
Leave a comment »

  1. This code works great for a single iframe, but how do you get it to reload various iframes @ different intervals? I have 3 iframes that i would like to load @ different time frames, but as im inexperienced do coding & java, im not sure how to apply your method to multiple iframes. Any help would be greatly appreciated!

Leave Comment