UWP Based project, WebView with DOM Explorer

巧了我就是萌 提交于 2019-12-14 04:03:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!