VB.Net - 如何在 GeckoFX60 中获得新的 window URL

VB.Net - How to get new window URL in GeckoFX60

如何从 GeckoFX60

中新打开的 window 中获取 url

C#代码:

void wb1_CreateWindow2(object sender, GeckoCreateWindow2EventArgs e)
    {
        e.Cancel = true;
        e.WebBrowser.Navigate(e.Uri);
    }

但我在 vb.net

中找不到 e.Uri

我试过 e.WebBrowser.Url.AbsoluteUri 但它总是空的

这是我在 vb.net

中尝试过的
Private Sub GeckoWebBrowser1_CreateWindow(sender As Object, e As Gecko.GeckoCreateWindowEventArgs) Handles GeckoWebBrowser1.CreateWindow
    Try
        e.Cancel = True
        Console.WriteLine(e.WebBrowser.Url.AbsoluteUri)

    Catch ex As Exception

    End Try
End Sub

在 GeckoFX 60.x 的 GeckoWebBrowser 的 CreateWindow 事件中,e GeckoCreateWindowEventArgs 对象上没有 Uri 属性。

要获取 URL 创建一个新的 GeckoBrowser 实例,然后在 Navigating 事件

中获取 URL

Here's 来自 GeckoFX 论坛相关主题的一些示例代码:

Private Sub Gecko_CreateWindow(sender As Object, e As GeckoCreateWindowEventArgs) Handles Gecko.CreateWindow
    'Create new form & initialise the browser
    Dim Frm As New GeckoFrm
    Dim h = Frm.Gecko.Handle

    'Keep flags for use in Navigating event
    If e.Flags = GeckoWindowFlags.All Then
        Frm.Gecko.SetContextFlagsAttribute(ContextFlags.Tab)
    Else
        Frm.Gecko.SetContextFlagsAttribute(ContextFlags.Popup)
    End If

    'Pass back the browser
    e.WebBrowser = Frm.Gecko
End Sub

Private Sub Gecko_Navigating(sender As Object, e As GeckoNavigatingEventArgs) Handles Gecko.Navigating
    If Gecko.GetContextFlagsAttribute And ContextFlags.Tab Then
        'Navigate existing or open tab
        NavigateTab(e.Uri.ToString)
    ElseIf Gecko.GetContextFlagsAttribute And ContextFlags.Popup Then
        If BlockPopup()
            e.Cancel = True
            Return
        Else
            'navigate existing or open popup
            NavigatePopup(e.Uri.ToString)
        End If
    Else
        'Not a popup, just show 
        Show()
    End If
    'Clear the popup/tab flags
    Gecko.SetContextFlagsAttribute(0)
End Sub