Re: WebBrowser Control (VB5, VB6) & window.external. Possible?
- From: ClarkVent <ClarkVent@xxxxxxxxxxx>
- Date: Wed, 23 Jul 2008 16:46:18 +0200
What I'm trying to do is the following. I have a WebBrowser control hosted inside a VB5/VB6 form. The WebBrowser control loads a HTML page and in that HTML page I want to be able to query the hosting VB5/VB6 application for some variables through JavaScript (or any other means).
For instance, in the HTML page:
<SCRIPT>
function showVersionNumber() {
var cn = window.external.getVersionNumber();
alert( cn );
}
</SCRIPT>
Then in the VB5/VB6 application:
Public Function getVersionNumber() as String
getVersionNumber = App.Major & "." & App.Minor
End Function
This is just an example, I'm not really trying to get the version number, I just want to be able to query the hosting VB5/VB6 application. I know I can simply "inject" variables into the HTML code, but the variables I want to query are dynamic so their values must be generated at the moment of the query.
Thanks again in advance.
mayayana wrote:
It might help if you explain what exactly you're.
trying to do. The WB events are available in the
form code without any extra effort. If you want
the document events in order to time calls to
form-related functions, first declare in the form:
Private WithEvents Doc As mshtml.HTMLDocument
(Requires a reference to mshtml.dll.)
Then in WB.document_complete do something
like the following:
Private Sub WB_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Set Doc = Nothing
IsDoc = False
If Not WB.document Is Nothing Then
Set Doc = WB.document
IsDoc = True
End If
End Sub
In that example IsDoc is a global variable. Since
the document object is gone with each page load,
in order to avoid referencing an empty doc object
it helps to keep track of it. I find it works well to
do like above and then in WB_BeforeNavigate set
IsDoc = False. Using that method means that you
always get your relevant Doc events and that you
can also safely reference the doc object by using:
If IsDoc = True then....
I'm trying to communicate between a WebBrowser control and its VB5/VB6
container. I know that in VS2005 it's as easy as defining a public sub
in the application:
Public Sub doSomething()
' Do Something!
End Sub
and in the document call
window.external.doSomething
This apparently does not work in VB5/VB6. Is there any way to do this or
something similar?
Thanks in advance.
- Follow-Ups:
- References:
- WebBrowser Control (VB5, VB6) & window.external. Possible?
- From: ClarkVent
- Re: WebBrowser Control (VB5, VB6) & window.external. Possible?
- From: mayayana
- WebBrowser Control (VB5, VB6) & window.external. Possible?
- Prev by Date: Re: FolderExist and UNC Path Problem
- Next by Date: Re: File write without linebreak
- Previous by thread: Re: WebBrowser Control (VB5, VB6) & window.external. Possible?
- Next by thread: Re: WebBrowser Control (VB5, VB6) & window.external. Possible?
- Index(es):