Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 or the HTML currently being rendered in the WebView? My need is to parse the HTML that is being displayed so either would work.

like image 957
Brent Schooley Avatar asked Dec 21 '11 22:12

Brent Schooley


1 Answers

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.

like image 165
Brent Schooley Avatar answered Jan 01 '23 21:01

Brent Schooley