我需要将HTML嵌入Winforms项目中,并从中调用Javascript函数。我在C#项目中使用webBrowser控件并调用:
webBrowser.Navigate("website");
return webBrowser.Document.InvokeScript("myMethod", new object[]{"test"});
当调试器位于“myMethod”中时,如何调试代码执行?
这篇文章介绍了如何从IE调试HTML:
http://www.codeproject.com/Articles/18921/Using-Visual-Studio-to-Debug-JavaScript-in-IE
我不知道它有多重要。
最佳答案
在网站的“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;
//
...
...
}
“debugger”语句将提示您调试JavaScript。
当myMethod执行时,将提示您
您要执行的调试器,然后从提示符下选择“Visual Studio 2xxx的新实例”
希望这会有所帮助。