在WebBrowser控件中调试HTML

Dav*_*vid 7 .net html javascript c# visual-studio-2010

我需要在Winforms项目中嵌入HTML并从中调用Javascript函数.我在ac#项目中使用webBrowser控件并调用:

webBrowser.Navigate("website");
return webBrowser.Document.InvokeScript("myMethod", new object[]{"test"});
Run Code Online (Sandbox Code Playgroud)

当调试器在"myMethod"中时,如何调试代码的执行?

这篇文章是关于如何从IE调试HTML的:http: //www.codeproject.com/Articles/18921/Using-Visual-Studio-to-Debug-JavaScript-in-IE

我不知道它有多相关.

Par*_*ram 13

在您网站的"myMethod"功能中添加以下"调试器"行 - \

function myMethod(arg1, arg2)
{
    // when myMethod executes you will get prompt that with which 
     // debugger you want to execute
    // then from prompt select "New Instance of Visual Studio 2xxx"
    debugger; 

    //
    ...
    ...
}
Run Code Online (Sandbox Code Playgroud)

"debugger"语句将提示调试JavaScript.

当myMethod执行时,您将获得提示您要执行哪个调试器然后从提示选择"Visual Studio 2xxx的新实例"

希望这会有所帮助.

  • 我必须取消选中"Internet选项中的禁用脚本调试(其他)"才能使其正常工作. (2认同)