Raise VB Methods/Events from IE and/or JavaScript
According to article "Take Total Control of Internet Explorer with Advanced Hosting Interfaces", http://www.microsoft.com/mind/advhost/advhost.htm, one should be allowed to call procedures from within the web application to a host application. ie you write your own program embedding the webbrowser control (shdocvw.dll)
Has anyone been successful at doing this in a VB App?
To say it in a different way, I want to be able to access my VB functions through my VBScript and/or JavaScript.
If a user clicks on an item in my webbrowser control, I want vb to control where the webbrowser navigates to next (navigating I know how to do).
I read the artical above, but could not get my VB procedures to run. Here's my test code:
'VB Code with webbrowser control named webbrowser1
Option Explicit
Private Sub Form_Load()
WebBrowser1.Navigate "test.html"
End Sub
Public Sub whatsup()
MsgBox "Whatsup!"
End Sub
'test.html source code
<html>
<script language="VBScript">
sub ShowData
msgbox "blah"
window.external.whatsup
End Sub
</script>
<input type=button onclick="ShowData"></a>
</html>
When I click the button, obviously my click event is firing because I see the message box say "blah". However, I do not see the "Whatsup!" appear as I expect.
Your expertise on this subject would be greatly appreciated!
-Elias