Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted (edited)

Not sure if this will be classed as Ok for the Code section , but here ya go .

I've noticed on a few boards that people have been asking about the " BeforeNavigate2 " event not triggering when using the AxWebBrowser control , so i decided to tackle the problem and here's the result :

   Private WithEvents doc As SHDocVw.DWebBrowserEvents_Event
   '/// doc will handle all the events for brWeb now...
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Dim b As Object = brWeb.Application
       doc = DirectCast(b, SHDocVw.WebBrowser_V1) '///set doc as the active handler for brWeb's events.
   End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       brWeb.Navigate("http://google.com") '///lets navigate to a website.
   End Sub

   Private Sub doc_BeforeNavigate(ByVal URL As String, ByVal Flags As Integer, ByVal TargetFrameName As String, ByRef PostData As Object, ByVal Headers As String, ByRef Cancel As Boolean) Handles doc.BeforeNavigate
       MessageBox.Show(URL) '/// check that before navigate now works.
   End Sub

   Private Sub doc_StatusTextChange(ByVal [Text] As String) Handles doc.StatusTextChange
       Label1.Text = Text '///show the status text in a label.
   End Sub

   Private Sub doc_TitleChange(ByVal [Text] As String) Handles doc.TitleChange
       MyBase.Text = Text '/// set the form's caption to the current url
   End Sub

 

it may help a few people atleast :)

webbrowser.zip

Edited by PlausiblyDamp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...