基于UWP的项目,带有DOM Explorer的WebView [英] UWP Based project, WebView with DOM Explorer

查看:116
本文介绍了基于UWP的项目,带有DOM Explorer的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有这样的图书馆,或者是否有人可以给我提示如何实现这样的东西。

I was wondering if there's such a library or if anyone could give me hints on how to implement something like this.

我确切想要的是DOM Explorer的功能(更具体地说,当您在任何浏览器上并在DOM Explorer弹出窗口中击中F12窗口时,便可以通过它浏览HTML和CSS的各个方面)。我想知道是否有可能为WebView创建此功能,如果可以,请欣赏任何示例。

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.

注意:我正在Visual Studio 2015,WinRT(Windows Universal 8.1),C#项目上工作。

Note: I am working on Visual Studio 2015, WinRT(Windows Universal 8.1), C# project.

谢谢!

推荐答案

目前探索DOM的唯一方法是使用WebView.InvokeScriptAsync()方法调用javascript函数。因此,我想如果您在WebView.DomContentLoaded事件处理程序中执行以下操作:

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;" });

您将在 result 变量中获得完整的DOM。

you'll get full DOM in the result variable.

这篇关于基于UWP的项目,带有DOM Explorer的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆