WebHTMLViewer: Scrolling

In a WebApplication I have a WebHtmlViewer.

It displays some Text, that is stored in a property

The Text constantly grows, the WebHTMLViewer reloads and at some point in Time, the content of the text exceeds the available Space.

Is it possible to autoscroll the WebHTMLViewer to its bottom by using JavaScript?

I tried

WebHTMLViewer.ExecuteJavaScript(“document.getElementById(’” + lobbychat.ControlID + “_inner’).scrollIntoView(false);”)

But this returns an Error

Could not execute returned javascript: null is not an object (evaluating ‘document.getElementById(‘WzX6z22y_inner’).scrollIntoView’)
Source: document.getElementById(‘WzX6z22y_inner’).scrollIntoView(false);

Is the content of the WebHTMLViewer on the same site as your app ?

Meanwhile I don’t get a JS Error anymore. The “_inner” was wrong (although copied from Xojo Doch…)

The Content is stored in a String Property in the Application and looks like

My Text to Show

My Text to Show

My Text to Show

It is displayed with

That works fine

But scrolling does not work. I try with

WebHTMLViewer.ExecuteJavaScript(“document.getElementById(’” + WebHTMLViewer.ControlID + “’).scrollIntoView(false);”)

no error but also no scrolling.

WebHTMLViewe.ExecuteJavaScript(“document.getElementById(’” + WebHTMLViewe.ControlID + “’).scrollTop = document.getElementById(’” + WebHTMLViewe.ControlID + “’).scrollHeight;”)

Also no err, but no scrolling

What you’re doing is telling the htmlviewer’s inner page to scroll the htmlviewer’s ID into view.
That’s not going to scroll the inner contents of the htmlviewer.

There’s a lot of things that come into play, and some experimenting I’d have to do before I could offer any more advice than that. I may have more for you later!

I’ve got a solution:

I include the Scroll order in the HTML that is displayed

ShowHTML= “<body onload=”“window.location=’#scrollhere’;”">"


ShowHTML=ShowHTML+"<div id="“scrollhere”" name="“scrollhere”">"



As the WebHTMLViewer shows the Page in an iframe, this works as expected.

FWIW you can access the WebHTMLViewer document as an iFrame

BUT (very big but) it works only if the content is on the same site as your app. If you display the content of another site, iFrame security won’t let you access it.