简体   繁体   English

在Visual Studio 2008中为JavaScript设置断点时出现问题

[英]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. 我正在尝试在Visual Studio 2008中调试JavaScript。我使用ASP.NET MVC,jQuery和jQueryUI。

I can set a breakpoint, but when I start debugging Visual Studio changes the breakpoint icon to one with a warning. 我可以设置一个断点,但是当我开始调试时,Visual Studio会将断点图标更改为带有警告的图标。 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. 在IE8中,对于IE和其他浏览器,我均未选中“禁用脚本调试”。

My JavaScript code is very simple and not dynamically generated. 我的JavaScript代码非常简单,并且不会动态生成。 What am I missing? 我想念什么?

Try typing the code "debugger;" 尝试输入代码“ debugger;”。 in the place where you want the breakpoint. 在您想要断点的地方。 When IE hits that line, it should stop whether a debugger is attached or not. 当IE到达该行时,无论是否连接调试器,它都应停止。

Visual Studio will do what you described during startup, since the code isn't being run yet. 由于尚未运行代码,因此Visual Studio将执行您在启动期间描述的操作。 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.) (VS将在调试过程中为某些JavaScript创建临时文档,如果在一个调试会话期间在其中放置断点,则这些断点将不适用于下一个调试会话。)

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. 如果您正在使用“ Web应用程序”项目,则还应该检查web.config文件以确保已启用调试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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