|
-
May 7th, 2016, 10:34 PM
#1
Thread Starter
Junior Member
VB6 - WebBrowser HTML button intercept click
Hi,
When a page loads, I need to intercept one of the Named buttons that appear on screen and stop the button opening another page, when clicked by the User.
I would presume that it will happen in BeforeNavigate, but what code do I use to destroy the call to the HTML page under the clicked button?
Thanks.
-
May 8th, 2016, 12:29 AM
#2
Re: VB6 - WebBrowser HTML button intercept click
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 8th, 2016, 12:13 PM
#3
Re: VB6 - WebBrowser HTML button intercept click
Code:
Private Sub Command1_Click()
WebBrowser1.Navigate "http://www.some-website.com"
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
If InStr(URL, "http://www.some-website.com") > 0 Then
If MsgBox("Do you want to see the page?", vbYesNo, "See Page?") = vbYes Then
Cancel = False
Else
Cancel = True
End If
End If
End Sub
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
May 9th, 2016, 06:48 AM
#4
Thread Starter
Junior Member
Re: VB6 - WebBrowser HTML button intercept click
jmsrickland, that should do the trick. Many thanks to yourself and westconn1 for answering.
Cheers.
Tags for this Thread
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
|