views:

144

answers:

1

I'm trying to debug JavaScript in Visual Studio 2008. I use ASP.NET MVC, jQuery, and jQueryUI.

I can set a breakpoint, but when I start debugging Visual Studio changes the breakpoint icon to one with a warning. Hovering over the icon then reveals a tooltip which says:

"The breakpoint will not currently be hit.  The document is not loaded."

In IE8, I have "Disable Script Debugging" unchecked for both IE and other browsers.

My JavaScript code is very simple and not dynamically generated. What am I missing?

+1  A: 

Try typing the code "debugger;" in the place where you want the breakpoint. When IE hits that line, it should stop whether a debugger is attached or not.

Visual Studio will do what you described during startup, since the code isn't being run yet. Are you sure that the code has been loaded into the browser when you're looking at the debugger? If the code has already run and it still shows the document as not loaded, then you could be placing the breakpoint in the wrong version of the file. (VS will create temporary documents for some JavaScript during debugging, if you put breakpoints there during one debug session, they won't work for the next debug session.)

Edit

If you are working with a "web application" project, you should also check the web.config file to make sure you have debugging enabled.

John Fisher
Thanks for the "debugger;" hint. I didn't know about that.I believe the code has been loaded when I'm looking at the debugger. I can debug more-or-less OK with Firebug, so I think I have the hang of the general idea. Where should I look for the temporary documents you mention?
Slack
The temporary documents just appear automatically, and generally close when you stop debugging. They are generated when you step into or break at an error in some javascript that doesn't have a direct source file (for example some "eval" script).
John Fisher