How can i get url from new opened window in GeckoFX60
C# code:
void wb1_CreateWindow2(object sender, GeckoCreateWindow2EventArgs e)
{
e.Cancel = true;
e.WebBrowser.Navigate(e.Uri);
}
but i can't find e.Uri in vb.net
i tried e.WebBrowser.Url.AbsoluteUri but it always null
this is what i tried in 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
In GeckoFX 60.x on the CreateWindow event of the GeckoWebBrowser there is no Uri
property on the e
GeckoCreateWindowEventArgs object.
To get the URL create a new instance of GeckoBrowser, then you get the URL in Navigating event
Here's some sample code from a related thread on the GeckoFX forum:
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