Debugging HTML in WebBrowser Control

.net, c#, html, javascript, visual-studio-2010

Solution

Add following "debugger" line in your website's "myMethod" function -\

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" statement will prompt for debugging the JavaScript.

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"

Hope this will help.

Problem

I need to embed HTML in a Winforms project and call Javascript functions from it. I'm using a webBrowser control in a c# project and calling: ``` webBrowser.Navigate("website"); return webBrowser.Document.InvokeScript("myMethod", new object[]{"test"}); ``` How can I debug execution of code when the debugger is in "myMethod"? There's this article on how to debug HTML from IE: http://www.codeproject.com/Articles/18921/Using-Visual-Studio-to-Debug-JavaScript-in-IE I don't know how relevant it is though.

Original source