VerticalScrollPosition for HTMLviewer

There does not appear to be a verticalScrollPosition for the HTMLviewer as there is for TextArea. Is there a way to remember and restore a scroll position in the HTMLviewer?

It appears the when you post, HTMLviewer of course show beginning from the top of the page. At the very least is there a way to tell it to go to the bottom of the page?

1 Like

You’ll need to use JavaScript for this. I have some code for it, but I’m out of the office until tomorrow morning. Essentially, you want to capture the scroll even of the page, return the X/Y using executeInXojo, store that date in the JavaScriptRequest event and restore it using yet more JavaScript upon page reload.

1 Like

OK, here’s a simple example. I’ve created a subclass that hooks the window’s scroll event and saves the X/Y positions. The scroll positions are stored in a Dictionary and re-applied as the user navigates. It’s all commented and fairly straightforward.

htmlviewer_scroll_example.xojo_binary_project.zip (7.6 KB)

3 Likes

Thanks Anthony. I have not had a chance to stare at it for long yet, but sounds like exactly what I need.

1 Like