Reputation: 215
Sometimes when I click on a link, it opens in a new window. Can I prevent this from happening and just load the page in my current window?
Upvotes: 1
Views: 2080
Reputation: 362
This is working for me (so far):
Private Sub browser_NewWindow(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles browser.NewWindow
e.Cancel = True
browser.Navigate(browser.StatusText)
End Sub
Really simple, if the status text is the url (which it always is for the documents I am browsing)
Upvotes: 3
Reputation: 15281
If you are targeting Windows XP SP2 or later, you can catch the NewWindow3 event to get the target url, and after setting the cancel parameter, navigate to the url instead.
For earlier versions of IE you can catch the obsolete NewWindow event with the same handling as documented in Q185538 How To Cause Navigation to Occur in Same WebBrowser Window
Upvotes: 0