locked
Opening Links In new tabs in my tabbed webbrowser RRS feed

  • Question

  • hello guys i have made a tabbed webbrowser with a lot of Features :)

    but i have a big problem :(

    whenever i click on a link or anything that opens a new tab it opens  a new tab in internet explorer instead of my browser :(

    i want to stop internet explorer from popping up and open new tabs in my tabbed webbrowser instead

    i am using Visual Studio 2013

    i already figured out how to open a new tab but can't stop internet explorer from showing and can't make the new tab navigate to the clicked link

    here's my code for the 

    form1_load


    Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Page")
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homepage)
        Browser.ScriptErrorsSuppressed = True
    End Sub

    Code for the new tab button:

    Public Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Page")
        TabControl1.SelectTab(int)
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homepage)
        Browser.ScriptErrorsSuppressed = True
    End Sub

    the code that i use to open a new tab in my browser when a link is clicked but can't make the new tab navigate to the clicked URL:

    Private Sub Done(sender As Object, e As WebBrowserDocumentCompletedEventArgs)
        'Throw New NotImplementedException
    
        For Each element As HtmlElement In sender.Document.Links
            AddHandler element.Click, AddressOf OpenNewTab
        Next
    
    End Sub
    
    Private Sub OpenNewTab(sender As Object, e As HtmlElementEventArgs)
        Public Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        Dim Browser As New WebBrowser
        TabControl1.TabPages.Add("New Page")
        TabControl1.SelectTab(int)
        Browser.Name = "Web Browser"
        Browser.Dock = DockStyle.Fill
        TabControl1.SelectedTab.Controls.Add(Browser)
        AddHandler Browser.ProgressChanged, AddressOf Loading
        AddHandler Browser.DocumentCompleted, AddressOf Done
        int = int + 1
        CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.homepage)
        Browser.ScriptErrorsSuppressed = True
    End Sub
    End Sub

    please help me guys and i would like to add new codes instead of replacing with a new code but any help would appreciated :)

    ~ Thanks in Advance ~

    Tuesday, September 22, 2015 7:30 PM

Answers