Here is what you do to get the current URL.
Code in a button. To obtain the URL after the last part of the page has loaded, reset a timer in each Document Complete, so after the last one has elapsed, the timer fires :
Sub Action()
HTMLViewer1.ExecuteJavaScript("document.title='zurl '+document.URL;")
End Sub
You get the URL in the Titlechanged event :
Sub TitleChanged(newTitle as String)
if instr(newTitle,"zurl")>0 then
dim myURL() as string = split(newTitle, "zurl")
msgbox myURL(1)
end if
End Sub
Note the ‘zurl’ label I used to identify the title in which the URL is sent back from the JavaScript. You can also use it to distinguish between the JavaScript result and the regular title.
I used the cnn.com site which is a good example of a site that takes you to another location.
cnn.com in fact ends up as edition.cnn.com after going through three intersticial pages.