|
-
Jul 21st, 2001, 02:53 PM
#1
Thread Starter
Hyperactive Member
I need a Link in the WebBrowser control to run VB procedure
I have a WebBrowser control displaying a webpage. I want the Command1_Click procedure to be run when a user clicks on a specific link on the webpage. Is this possible?
-
Jul 21st, 2001, 03:21 PM
#2
Frenzied Member
Check this link out for sinking document events for the webbrowser. This should get you headed in the right direction
http://support.microsoft.com/support.../Q246/2/47.asp
-
Jul 21st, 2001, 04:50 PM
#3
Thread Starter
Hyperactive Member
Thanks Rye... that's what I ended up doing.
VB Code:
Private Sub brwWebBrowser_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
If Left$(URL, 6) = "event:" Then
Select Case Mid(URL, 7)
Case "RunMyCode"
' Put the code that you want to run here
Cancel = True
End Select
End If
End Sub
Now... in the html put this:
Code:
<HTML>
<BODY>
<A HREF="EVENT:RunMyCode">Click here</A> to run my VB code.
</BODY>
</HTML>
-
Jul 22nd, 2001, 12:02 AM
#4
Thread Starter
Hyperactive Member
Ok... say I have a textbox in a form on my HTML page... how can I tell VB to put certain text in that box?
-
Jul 22nd, 2001, 07:50 AM
#5
Frenzied Member
Look in the html code for the "name" of the textbox.
Let's say you do and the name is "username".
Now in the DocumentComplete Event code it something like this.
VB Code:
If (pDisp is WebBrowser1.Object) Then
WebBrowser1.Document.All("username").Value = "what-ever"
End If
When you navigate to the page that has that textbox, "what-ever"
will be displayed in the textbox.
-
Jul 22nd, 2001, 10:57 AM
#6
Thread Starter
Hyperactive Member
Thanks bloodeye... that worked.
But for some reason my WebBrowser control doesn't have that pDisp variable in the subroutine heading. Mine says:
VB Code:
Private Sub brwWebBrowser_DownloadComplete()
So I just didn't use the if statement and it seems to work fine (I did say On Error Resume Next)... that's why.
Any clue why I don't have that pDisp value?
-
Jul 22nd, 2001, 01:42 PM
#7
Frenzied Member
Your in the wrong event.
No big deal, DownloadComplete and DocumentComplete look the same when choosing from a list. I make that mistake myself...
-
Jul 22nd, 2001, 02:31 PM
#8
Thread Starter
Hyperactive Member
I guess I need to open my eyes! Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|