我在WPF应用程序中使用geckofx-22。我想检查geckofx控件中加载的页面的当前URL。找不到相同的任何属性。
将以下代码用于WPF,并将其放在Geckofx-WPF GeckoWebBrowser.cs中
/// <summary>
/// Gets the <see cref="Url"/> currently displayed in the web browser.
/// Use the <see cref="Navigate(string)"/> method to change the URL.
/// </summary>
[BrowsableAttribute(false)]
public Uri Url
{
get
{
if (_webNav == null)
return null;
nsIURI locationComObject = _webNav.GetCurrentURIAttribute();
var uri = locationComObject.ToUri();
Xpcom.FreeComObject(ref locationComObject);
return uri ?? new Uri("about:blank");
}
}
然后,您可以按以下方式访问网址
geckoWebbrowser.Url;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句