简体   繁体   中英

How to get current URL of webview in windows 8 Apps | C#, XMAL

How can I get the URL of currently opened page in webview?

Actually I want to create a login scenario. so that I can integrate my university site for real-time notifications of assignments and quiz's.

Thanks in advance

Another idea would be to use InvokeScript and get the info from the document using javascript. Something like:

var url = await myWebView.InvokeScriptAsync("eval", new String[] { "document.location.href;" });

Hope it helps someone.

There's no direct property. You have to use LoadCompleted event.

private void WebView_LoadCompleted(object sender, NavigationEventArgs e)
{
    System.Diagnostics.Debug.WriteLine(e.Uri.ToString());
}

It should be noted that the WebView_LoadCompleted event has been deprecated & is/will be obsolete. It may not be available after Windows 8.1 so you should use the NavigationCompleted event instead.

private void myWebView_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
    {    
        string myUrl = sender.Source.ToString();    
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM