问题
I was wondering if there's such a library or if anyone could give me hints on how to implement something like this.
What I want exactly is the functionality of DOM Explorer (to be more specific, when you are on any browser and hit F12 window with DOM Explorer pops where you can look through various aspects of HTML and CSS). I want to know if it would be possible to create this function for WebView and if so, any example would be appreciated.
Note: I am working on Visual Studio 2015, WinRT(Windows Universal 8.1), C# project.
Thanks!
回答1:
The only way to explore DOM right now is to invoke a javascript function with WebView.InvokeScriptAsync() method. So, I suppose if in your WebView.DomContentLoaded event handler you do something like this:
var result = await this.webView.InvokeScriptAsync("eval", new[] { "document.documentElement.outerHTML;" });
you'll get full DOM in the result variable.
来源:https://stackoverflow.com/questions/39837631/uwp-based-project-webview-with-dom-explorer