Is there a way to programmatically scroll the Webhtmlviewer in 2026 R1.2? (most recent release at the time of this post). I’m trying to get an app compliant with WCAG guidelines for keyboard navigation and I can’t figure out a way to scroll the html viewer by any means other than the mouse or trackpad gestures.
I found an entry posted from 2017 using the code below, but it doesn’t seem to affect anything:
self.ExecuteJavascript(“document.getElementById(‘” + htmlviewer1.ControlID + “’).getElementsByTagName(‘iframe’)[0].contentDocument.scrollTo(0, 0);”)
Hi
The scrollTo method is on the window not the document so you’d need to call it by targeting the iframe like:
iframe.contentWindow.scrollTo(x,y)
Oh, so what I’m trying to implement is a page with a list of articles on the the left hand side and an HTML viewer on the right side. You select an article in the list and it is visible in the HTML viewer. That portion works with keyboard control (thanks to GraffitiSuite), but I can’t figure out how to enable keyboard controls or clicking a button to scroll the HTML viewer.
Does this mean that the document would have to be opened in its own window with no other controls for the iframe method to work?
My new application uses a lot of javascript for navigating the main html viewer. But the basic javascript is like the one above. How do you use javascript in a webapp? In the desktop javascript I inject the code and get an event back. Or do you need to use the web sdk for a web app to things like that?
If your iframe and the app’s page don’t have the same origin, contentDocument will be null. This is part of cross-origin security policies (reference).
There aren’t any great ways to get around this, really…
If you control the page(s) with the articles, you could embed some JavaScript there so that you could send and receive messages to perform otherwise forbidden operations.
If you don’t control the content page(s) then you probably want to be looking for an acceptable method of consuming and presenting the content, like an RSS feed.