简体   繁体   中英

Problems setting breakpoints for JavaScript in Visual Studio 2008

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM