网页浏览器 [英] Web Browser

查看:109
本文介绍了网页浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好社区!

我在按新URL时制作标签时遇到了大问题

I have a big problem regarding on making tabs when pressing a new URL

对于启动,我有以下代码来创建选项卡,并为创建另一个选项卡提供了一个按钮,这很简单:

I have this code for the start up to make the tab and a button to make another tab this is simple:

将昏暗"标签设为新的TabPage
      将newtab设为新标签
       newtab.Show()
       newtab.Dock = DockStyle.Fill
       newtab.TopLevel = False
       tab.Controls.Add(newtab)
       Me.TabControl1.TabPages.Add(tab)
       Me.TabControl1.SelectedTab =选项卡

Dim tab As New TabPage
        Dim newtab As New tabs
        newtab.Show()
        newtab.Dock = DockStyle.Fill
        newtab.TopLevel = False
        tab.Controls.Add(newtab)
        Me.TabControl1.TabPages.Add(tab)
        Me.TabControl1.SelectedTab = tab

但是当按下链接并试图打开一个新标签时,我得到了这段代码,但是它坏了.

But when a link is pressed and is trying to open a new tab i have this code but its broken.

将WithEvents公开作为新的WebBrowser

Public WithEvents wb As New WebBrowser

e.Cancel = True

       'AddHandler browserTabControl1.SelectedIndexChanged,AddressOf tabcontrolchangeinputs
      将此元素变暗为HtmlElement = WebBrowser1.Document.ActiveElement
       Dim targeturl As String = thiselement.GetAttribute("href")






      将newtab变暗为新的TabPage
       browser.TabControl1.Controls.Add(newtab)
      将新形式变暗为新形式
       newform.Dock = DockStyle.Fill
       newform.FormBorderStyle = Windows.Forms.FormBorderStyle.None
       newform.TopLevel = False
       newtab.Controls.Add(newform)
       newform.Show()
       newform.Controls.Add(wb)
       browser.TabControl1.SelectedTab = newtab
       browser.TabControl1.SelectedTab.Controls.Add(newform)
       wb.Dock = DockStyle.Fill
       wb.Navigate(targeturl)

e.Cancel = True

        'AddHandler browserTabControl1.SelectedIndexChanged, AddressOf tabcontrolchangeinputs
        Dim thiselement As HtmlElement = WebBrowser1.Document.ActiveElement
        Dim targeturl As String = thiselement.GetAttribute("href")






        Dim newtab As New TabPage
        browser.TabControl1.Controls.Add(newtab)
        Dim newform As New Form
        newform.Dock = DockStyle.Fill
        newform.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        newform.TopLevel = False
        newtab.Controls.Add(newform)
        newform.Show()
        newform.Controls.Add(wb)
        browser.TabControl1.SelectedTab = newtab
        browser.TabControl1.SelectedTab.Controls.Add(newform)
        wb.Dock = DockStyle.Fill
        wb.Navigate(targeturl)

请帮助!

预先感谢!

推荐答案

您好,我认为您无需在tabcontrol中添加表单,然后添加将webbrowser添加到表单中,可以将webbrowser添加到tabcontrol,下面是示例代码:

Hi, I think you don't need to add a form to the tabcontrol and then add webbrowser to the form, you can add the webbrowser to tabcontrol, below is the sample code:

 Dim newtab As New TabPage
        browser.TabControl1.Controls.Add(newtab)
        newtab.Controls.Add(wb)
        wb.Show()
        browser.TabControl1.SelectedTab = newtab
        wb.Dock = DockStyle.Fill
        wb.Navigate(targeturl)


这篇关于网页浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆