HTML viewer that can intercept links and scroll

The built-in WebHTMLViewer has the ability to scroll if the html content is larger than the control, but it doesn’t have the ability to intercept link clicks to have them processed by the webapp.

The WebSDK > HTMLArea example has the ability to intercept link clicks, but does not scroll if the content is larger than the control.

I can’t seem to get either solution to do both. The closest I’ve gotten so far is to use the WebDSK HTMLArea and use a div with overflow-y, but that runs into issues when the window is resized.

you intercept the links clicked in the CancelLoad event

This is for Web Edition, the WebHTMLViewer doesn’t have the CancelLoad event.

@shao sean I belive Tom is referring to the WebHtmlViewer which doesn’t appear to have a CancelLoad event. Your link is referring to the desktop HTMLView.

Tom beat me to it.

My bad… Need to figure out how to filter out the Web postings…

If the WebHTMLViewer has the DocumentComplete event, are you able to insert a JavaScript in to the DOM to handle the click event?

You can go to the channels list and click the gear for a forum, and choose Hide to ignore channels.

I have control over the html I’m sending to the control so I tried inserting javascript into the links beforehand, but the problem was getting an event back in the WebEdition app.

For now I’m just using a div with overflow-y set on the websdk htmlviewer example. Works fine except that I need to change the overflow-y value when the control is resized, which means I need to reload the source, and it then scrolls back to the top.

This was going to be my suggestion. Can you elaborate as to what “runs into issues” means?

I want the div to be the size of the window (similar to if I checked lock left, right, top, bottom for a WebHTMLViewer in the layout editor). Because of this, I have to change the overflow-y size whenever the page is resized.

I’m doing this using the Resized event, but once I change the overflow-y size I need to reload the html source into the viewer, which causes the page to be reset and the view to scroll to the top. Not the worst bug ever, but still annoying for anyone who resizes the window to view something and has the scroll randomly reset to the top of the page.

Set overflow-y to scroll.

Styles(0).value(“overflow-y”) = “scroll”

That will make the adjustment happen on the browser side without the need for the resized event.

Thanks Greg. I already had that in there, but you also have to set the height for the actual div or else it won’t know when to begin “overflowing.” This is what was causing the issue.

I’ve changed the height for the div from a fixed value to “100%” and it’s working better now. I seem to remember hearing that setting a div to 100% height won’t always work, but it’s working for now.