有没有一种方法,使从内WebBrowser控件IE8的开发工具在.NET应用程序控件、开发工具、应用程序、方法

由网友(人心对人心必有黑心人)分享简介:如果你有IE8,您可能已经注意到,MS又增加了一个非常方便的功能。命中F12和开发工具,如调试器Firebug的,弹出。这对于调试非常有用,我不知道是否有一种方法,弹出的开发工具的从.NET应用程序中WebBrowser控件。If you have IE8, you may have noticed a really...

如果你有IE8,您可能已经注意到,MS又增加了一个非常方便的功能。命中F12和开发工具,如调试器Firebug的,弹出。这对于调试非常有用,我不知道是否有一种方法,弹出的开发工具的从.NET应用程序中WebBrowser控件。

If you have IE8, you may have noticed a really handy feature that MS has added. Hit F12 and Developer Tools, a firebug like debugger, pops up. This is extremely useful for debugging purposes, and i'm wondering if there is a way to pop up the Developer Tools from a WebBrowser control inside a .NET application.

我的情况是这样的:我有一个C#应用程序,它具有一个嵌入式的WebBrowser控件。 C#的应用程序和DHTML网页浏览器的内容相互使用ObjectForScripting(C#端)和window.external(DHTML侧)接口进行通信,所以为了测试/调试/故障排除的完整功能,我需要一种方法来触发开发者工具从WebBrowser控件中。到现在为止,我们一直仅限于使用 Firebug的精简版这是严重限制或触发的JavaScript的使用步骤调试会话调试器; JS,但是现在我们正在的地步,这些选项成为一个真正的麻烦,并且不允许的全部功能,我们将走出具有类似萤火虫或开发者工具,在我们的处置。

My situation is this: I have a C# application that has an embedded WebBrowser control. The C# app and the DHTML web browser contents communicate with each other using the ObjectForScripting (C# side) and window.external (DHTML side) interfaces, so in order to test/debug/troubleshoot the full functionality, i need a way to trigger Developer Tools from within the WebBrowser control. Up to now we've been limited to using Firebug Lite which is severely limited or triggering a step debug session of the javascript using the 'debugger;' js, but now we're getting to the point where those options becoming a real hassle and don't allow the full features that we would get out of having something like Firebug or Developer Tools at our disposal.

我真正喜欢做的事情就是能够弹出开发工具,从里面的应用程序正在运行,而我的WebBrowser控件,但我还没有找到一种方法来做到这一点呢。

What I'd really love to do is to be able to pop up Developer Tools from inside my WebBrowser control while the app is running, but I haven't found a way to accomplish this yet.

有其他人遇到了这个问题,并发现,如果有一种方法可以做到这一点?

Has anybody else ran into this issue and found out if there's a way to make it happen?

推荐答案

没有,正如其他人说,这是不可能的。然而,有一种方法可以通过一个自定义处理程序连线大部分窗口的错误。 一旦文档完成加载就可以把监听器窗口。例如,

No, as others have said this is not possible. However there is a way you can wire most of the window errors through to a custom handler. Once the document has finished loading you can attach a listener to the window. e.g.

webBrowser.DocumentCompleted += (o, e) =>
{
    webBrowser.Document.Window.Error += (w, we) =>
    {
        we.Handled = true;

        // Do something with the error...
        Debug.WriteLine(
            string.Format(
               "Error: {1}nline: {0}nurl: {2}",
               we.LineNumber, //#0
               we.Description, //#1
               we.Url));  //#2
    };
};
阅读全文

相关推荐

最新文章