简体   繁体   English

我可以在VS 2012中的webbrowser控件中调试javascript代码吗?

[英]Can I debug javascript code in a webbrowser control in VS 2012

I would like to know if I can use the debugger in VS 2012 for javascript code in a webbrowser control for a winform app. 我想知道我是否可以在VS 2012中使用调试器来获取winform应用程序的webbrowser控件中的javascript代码。 I'm not talking about debugging in a web browser such as IE as this is not how I am running the code. 我不是在谈论在IE等网络浏览器中进行调试,因为这不是我运行代码的方式。 I have tried placing "debugger;" 我试过放“调试器”; in my javascript code but it still runs through it and does not stop. 在我的JavaScript代码中,它仍然贯穿它并且不会停止。

Here is an example of how I am using it. 这是我如何使用它的一个例子。

function addDeleteButton(poly, imageUrl) {
        debugger;
        var path = poly.getPath();
        path["btnDeleteClickHandler"] = {};

Thanks to Borys Generalov for this answer! 感谢Borys Generalov的回答!

The instructions for this can be found here http://blogs.perl.org/users/mark_leighton_fisher . 有关这方面的说明,请访问http://blogs.perl.org/users/mark_leighton_fisher

You can debug JavaScript executing inside a WebBrowser control embedded in your .NET 4.0 application from VS2010 (Visual Studio 2010), but it takes a little effort. 您可以在VS2010(Visual Studio 2010)中调试在.NET 4.0应用程序中嵌入的WebBrowser控件中执行的JavaScript,但需要花费一些精力。

  1. Enable Script Debugging (both IE and Other) in Internet Explorer. 在Internet Explorer中启用脚本调试(IE和其他)。
  2. Disable friendly HTTP messages in Internet Explorer. 在Internet Explorer中禁用友好的HTTP消息。
  3. Enable Display a notification about every script error in Internet Explorer. 启用在Internet Explorer中显示有关每个脚本错误的通知。
  4. Modify VS2010 to debug Script from the Attach Process dialog. 修改VS2010以从“附加进程”对话框中调试脚本。 Please note that you cannot debug both JavaScript (Script) and .NET 4.0 code at the same time. 请注意,您无法同时调试JavaScript(脚本)和.NET 4.0代码。 (I don't know why.) (我不知道为什么。)
  5. Add a debugger; 添加调试器; statement at the start of your JavaScript. JavaScript开头的声明。
  6. Start your WebBrowser-embedded application without debugging (Ctrl-F5). 无需调试即可启动WebBrowser嵌入式应用程序(Ctrl-F5)。
  7. When your application hits the JavaScript debugger; 当您的应用程序访问JavaScript调试器时; statement, select your current instance of VS2010. 声明,选择您当前的VS2010实例。
  8. Voilà! 瞧! You can now debug the JavaScript executing inside the WebBrowser control in your .NET 4.0 application. 您现在可以调试在.NET 4.0应用程序中的WebBrowser控件内执行的JavaScript。

This needs to be done regardless of ever using IE when debugging or running your code in VS 2012. 在VS 2012中调试或运行代码时,无论是否使用IE,都需要执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM