VB6 - WebBrowser HTML button intercept click-VBForums
Results 1 to 4 of 4

Thread: VB6 - WebBrowser HTML button intercept click

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Location
    Brisbane
    Posts
    16

    Question 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.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    22,874

    Re: VB6 - WebBrowser HTML button intercept click

    probably
    cancel = true
    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

  3. #3
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,072

    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.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2014
    Location
    Brisbane
    Posts
    16

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.