WebHTMLViewer URL not updating when user clicks on link

How can I obtain the current URL in a WebHTMLViewer control (2015r2.2) after the user has clicked on a hyperlink in a web page?

The control’s URL property doesn’t seem to update with the newly loaded page’s URL.

Thanks in advance!

The following code in a WebTimer:

Dim strJavaRequest, strQuery As String strJavaRequest = "{var xmlHttp = new XMLHttpRequest();xmlHttp.open(""GET"", ""/?"" + window.location.href, true); xmlHttp.send(null);}" HTMLViewerMain.ExecuteJavaScript(strJavaRequest)
Can return an address as a querystring intercepted in the following handleURL event (crude but effective):

Function HandleURL(Request As WebRequest) As Boolean if Request.QueryString <> "" then dim strQuery as string = Request.QueryString return true end if End Function
However the address returned as strQuery is that of the HTMLViewer not its content. Looks like I need something other than window.location.href to get a reference to the document in the WebHTMLViewer… Any ideas?

[quote=220726:@Eric Wilson]How can I obtain the current URL in a WebHTMLViewer control (2015r2.2) after the user has clicked on a hyperlink in a web page?

The control’s URL property doesn’t seem to update with the newly loaded page’s URL.

Thanks in advance![/quote]
The underlying control is purposely sandboxed by the browser, so getting what you want is not easy.

One possible cause is that the target url is set up do that it can’t be viewed in a frame.

That’s always a possibility but in this case the link is a simple URL that displays in the address bar when manually loaded in a browser window, so I guess I’m after a reference to the WebHTMLViewer’s browser iFrame …

If the iFrame is holding a page from the same domain that served up the web app then you should be able to get it via a custom web control and some execute javascript commands. You’d need to save off the controlID of the webHTMLViewer so you could reference it and in your tray plugin use that to get the first children[0] element and return it’s src or href property. Sorry, no better example yet, not enough coffee on board :wink:

Once they leave the domain though you’re running into cross scripting security stuff built into the browser. It physically won’t let you access content from another domain. (and a good thing generally too, wow what the spammers, crackers and scammers would do to us! you think add injection garbage is bad now :wink: I can imagine very complex examples of reparsing the original source and changing the links to hit your server first to report where they are going… Might be able to inject some javascript to do something like that on the first level of link following at least if you control the source of the original frame. Once they leave that though I think you’re out of luck.

Well I guess the only way to do this would be to build a proxy server using handleURL but I imagine it would not work with ssl. Thinking about this made me realise however just how much trust people put in proxies…