Horst Walter
Horst Walter

Reputation: 14071

Use VS2012 JavaScript debugging with Chrome (similar to IE)

With VS2012 and IE9 I can use the VS2012 JavaScript debugger from within VS2012 (similar to C#, ..). When I switch the browser to Chrome, I loose the ability to do so. I could switch to the the Chrome intrinsic debugger.

Chrome as browser

But, is there a way to get debugging with Chrome working with VS2012 (similat to IE)?

Example: Breakpoint hit with IE, but not with Chrome as browser.

Breakpoint

Remark: No duplicate of Debugging Websites with Google Chrome which is about .net debugging. I am not using any ASP.net, only JavaScript

Upvotes: 6

Views: 6791

Answers (4)

SausageFingers
SausageFingers

Reputation: 1846

This is now possible. See this page for how, but in a nutshell (using Windows 10 1607, Visual Studio 2015 with Update 3):

  1. Close all Chrome windows (this is important)
  2. From the Run prompt "chrome --remote-debugging-port=9222" (without quotes)
  3. In Visual Studio, start your application with Chrome as the browser. This opens your page in a new tab.
  4. In Visual Studio, with the application still running, click Debug -> Attach to Process... -> select the Chrome process that is running you page.
  5. This should attach to the process without any error and your break points in Visual Studio should now get hit.

Also, see this page which confirms this feature will be added to a future Visual Studio release.

Upvotes: 3

EBENEZER CURVELLO
EBENEZER CURVELLO

Reputation: 113

inside a javascript place a "debugger;" command and refresh the page.

works in CHROME v30> and IE 10>

Example:

<script type='text/javascript'>
        function LoginEstabelecimento() {

            var form = $('form#formLoginEstabelecimento');

            debugger;

           ... SOME REST OF CODE ...

        };
</script>

Upvotes: 6

Jani Hyyti&#228;inen
Jani Hyyti&#228;inen

Reputation: 5407

You can always right click the page in Chrome, choose 'inspect element' and use chrome's built-in javascript debugger.

Upvotes: 3

Rachel Henderson
Rachel Henderson

Reputation: 629

No it's absolutely impossible to debug JS in Chrome from VS, because it's a completely different internal engine. May be somebody will write a plugin for VS, but right now it's not possible.

Upvotes: 16

Related Questions