从webview Windows Universal获取url
在windows中使用webview时,无法获取正确的url。我使用的代码是:从webview Windows Universal获取url,windows,webview,win-universal-app,Windows,Webview,Win Universal App,在windows中使用webview时,无法获取正确的url。我使用的代码是: String host; String url; private void web_FrameContentLoading(WebView sender, WebViewContentLoadingEventArgs args) { if (host == args.Uri.Host) {
String host;
String url;
private void web_FrameContentLoading(WebView sender, WebViewContentLoadingEventArgs args)
{
if (host == args.Uri.Host)
{
url = host;
}
}
private void web_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
host = args.Uri.Host;
}
在xmal
<WebView x:Name="web" Grid.Row="1" HorizontalAlignment="Stretch" Source="https://m.youtube.com" FrameContentLoading="web_FrameContentLoading" NavigationCompleted="web_NavigationCompleted" />
有什么想法吗?为什么你说你没有正确的URL?您的代码看起来很好,那么您的问题是什么?如果您想要完整的URL,只需使用args.Uri(主机将返回主机名)。为什么您说您没有正确的URL?您的代码看起来很好,那么您的问题是什么?如果您想要完整的URL,只需使用args.Uri(主机将返回主机名)。