5

I often use this to debug JavaScript in IE (fiddle):

if (confirm("Debug from here?"))
    debugger;

If I choose "yes", I see the prompt to start Visual Studio just-in-time debugger, which I proceed with to debug the script in Visual Studio.

Now I want to use IE built-in debugger instead of Visual Studio. I use this workaround:

if (confirm("Debug from here?"))
    throw "debug";

It works, but I have to check "Continue after exception" in IE built-in debugger every time I hit throw. Also, throw is different from debugger (which just continues execution if debugging is disabled in IE options).

Is there a way to make debugger keyword to break into into IE built-in debugger (F12) rather than Visual Studio debugger?

Setting breakpoints in IE F12 tools, then refreshing the page with F5 is not an option, because the page is a postback.

EDITED. Chrome browser actually gives me the desired behavior. To see what I mean, open Chrome, hit F12 to open Dev tools, then navigate to http://jsfiddle.net/jTwsh. Click [OK] upon confirm and you should get into debugger right on the debugger line.

Kara
  • 6,115
  • 16
  • 50
  • 57
avo
  • 10,101
  • 13
  • 53
  • 81

2 Answers2

3

Suggest to disable the Just-In-Time debugger for Script; if you do not want to use it for.

See the below reference on how to enable/disable JIT Debugger:

Enable/Disable Just-In-Time Debugging

I am using IE8, there i need to start the script debugging by pressing 'Start Debugging' button or F5 under 'Script' tab in Developer Tools.

See the attached screenshot:

Developer Tools Screenshot

Ahsan Shah
  • 3,931
  • 1
  • 34
  • 48
  • If I disable it (or if I don't have Visual Studio installed at all), then using `debugger` in JavaScript simply does nothing and gets ignored. However, I want it to do what it's there for: break into IE F12 debugger. Am I missing something trivial? – avo Oct 21 '13 at 06:11
  • yes, you need to open the Developer Tools by pressing F12 and start debugging session. – Ahsan Shah Oct 21 '13 at 08:42
  • Doesn't work for me. Win8 64-bit, IE10, VS 2012, script debugging is enabled in IE options, JIT script debugging is disabled in VS option. I open a new IE window, navigate it to `about:blank` first to enable F12 tools, hit F12 to open F12 tools. Then I navigate to http://jsfiddle.net/jTwsh and `debugger` doesn't stop. Can anyone else confirm it actually works the way @AhsanShah has described it? – avo Oct 21 '13 at 09:15
  • It actually works for IE10 too. They key point is to click [Start Debugger] button in F12 toolbar *before* navigating to the page. Thank you! – avo Oct 21 '13 at 12:10
1

Don't run the website in debug. It is possible to run website in 'normal' runtime:

Right-Click on any page => View in browser

or ctrl+f5

Justin Lessard
  • 10,804
  • 5
  • 49
  • 61
  • I don't see how this answers the question. Could you clarify? I want to set a break-point, that's what `debugger` keyword does. I want my script to run normally until it hits that break point, and then I want to have any option to debug. – avo Oct 18 '13 at 04:25
  • If you hit the breakpoint while you're not in debug mode in visual studio, IE debugger should be used. – Justin Lessard Oct 18 '13 at 04:27
  • No, you hit Visual Studio debugger with `debugger`. Try this [fiddle](http://jsfiddle.net/jTwsh/) on a PC with Visual Studio installed. Make sure you have *Disable script debugging (Internet Explorer)* option unchecked in IE Advanced Options. You should see Visual Studio JIT Debugger prompt if you click [OK]. – avo Oct 18 '13 at 06:58