Conor Taylor
Conor Taylor

Reputation: 3108

Load changes from text file into HTML

I'm building a basic site to monitor a backend process. The process writes it's stdout to a file, and the site will constantly poll for changes in this file.

So far I have it working in an iframe that reloads every second. The problem is, the user can't scroll through the file, because once it reloads, it automatically scrolls back to the top of the file in the frame.

Are there any cleaner or alternative ways of doing this?

Upvotes: 0

Views: 48

Answers (1)

Jackson
Jackson

Reputation: 3518

You could try to grab the scroll position of the iframe before you reload the new url.

var scrollPosition = $('iframe').contents().find('body').scrollTop();

Then after you load the new url:

$('iframe').contents().find('body').scrollTop(scrollPosition);

Upvotes: 1

Related Questions