Can I get the current HTML or Uri for the Metro WebView control?

后端 未结 3 1096
一生所求
一生所求 2020-12-20 15:59

It doesn\'t appear that the Source property for the XAML WebView control is updating as the user is navigating in the WebView. Is it possible to get either the current Uri

相关标签:
3条回答
  • 2020-12-20 16:15

    The property you are looking for is called Source.

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.webview.source.aspx

    Unluckily the Document property of WinForms WebBrowser doesn't seem to exist anymore. You will have to re-download the page and process it using libraries like HtmlAgilityPack and Fizzler/FizzlerEx.

    0 讨论(0)
  • 2020-12-20 16:16

    Turns out that the WebView doesn't provide a way to retrieve its HTML directly. But you can use WebView.InvokeScript like this:

    webview.InvokeScript("eval", new string[] {"document.documentElement.outerHTML;"})
    

    You can also obtain the Uri via the LoadCompleted event's NavigationEventArgs.Uri.

    0 讨论(0)
  • 2020-12-20 16:19

    Did you look at the LoadCompleted event for WebView? That gives the URI that's just loaded.

    0 讨论(0)
提交回复
热议问题