带有 GeckoFX 的事件处理程序选项卡式 Web 浏览器

Event Handler Tabbed Web Browser With GeckoFX

我尝试用 geckofx 制作一个标签式网络浏览器。这是我制作新标签的代码:

    Dim t As New TabPage
    Dim bro As New GeckoWebBrowser
    bro.Dock = DockStyle.Fill
    t.Text = "New Tab"
    t.Controls.Add(bro)
    TabMain.TabPages.Add(t)
    TabMain.SelectedTab = t
    bro.Navigate("http://www.google.com")

现在,如何处理GeckoWebBrowser中的DocumentCompleted和DocumentTitleChanged?我想在触发 DocumentCompleted 事件时显示消息,并在触发 DocumentTitleChanged 事件时更改 window 标题。

不清楚vb.net语法,但原理很简单(从c#转vb应该也很简单)

因此,例如: 1) 将事件处理程序附加到您的浏览器

browser.DocumentCompleted += browser_DocumentCompleted;

2) 生成将执行您需要的方法:

void browser_DocumentCompleted(object sender, Gecko.Events.GeckoDocumentCompletedEventArgs e)
        {
            GWB browser = (GWB)sender;
            if (browser.Document == null) return;
            //do anything you wanna do when document is completed
            AnyMethodBasedOnBrowser(browser);

            //e.g. access GUI elements by property binding 
            TabTitle = "Complete";

            //or even alternatively access the control directly
            var TabControl = browser.Parent;
            //etc etc
        }

这应该对你有用!