This post originated from an RSS feed registered with Java Buzz
by Sam Dalton.
Original Post: Refreshing a Frame with No Jump Back
Feed Title: import java.*;
Feed URL: http://www.samjdalton.com/pebble/rss.xml
Feed Description: Random, Infrequent Bloggings of a Techie
Several times in the past I have come across the situtation where I want to constantly refresh an HTML page as the data on it is changing periodically. This is easy enough to do with JavaScript (using a timeout) or using the (non-standard) META REFRESH option.
With all but the smallest pages, this presents another problem. That is, that every time the page refreshes, it scrolls back to the very top of the page. This is obviously very undesirable with large pages of data, as the user will neve manage to stay at the item that they are interested in for very long before the page scrolls away.
In the past I have solved this problem using some very nasty JavaScripts (another frame refreshing, and updating our mainframe with JavaScript). This is all very well, but when you have complex tables of data this becomes unwieldy, resulting in a lot of code duplication between the JavaScript and the server side script that originally generated the page.
In an effort to steer clear of such nasty JavaScripts, I have found another way to achieve the same result.
This solution uses IFRAMES (a Microsoft only Floating Frame). Bassically, you create a container page with and IFRAME contained with in it. This IFRAME contains your constantly refreshing page. This page might look like the excerpt below: