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

后端 未结 3 1094
一生所求
一生所求 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: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.

提交回复
热议问题