How do I debug JavaScript in Visual Studio 2005?

2019-01-25 08:38发布

I just saw this mentioned in Stack Overflow question Best WYSIWYG CSS editor and didn't know it could be done. I'm a Visual Studio newbie, so how do you do it?

Is there a separate debugger for JavaScript? I know how to work the one for code-behind pages... I usually use Firebug to deal with debugging JavaScript code.

I'm using Visual Studio 2005.

11条回答
叼着烟拽天下
2楼-- · 2019-01-25 08:54

Debugging client JavaScript code in Visual Studio 2005:

Add the following code to the start of the JavaScript code:

debugger

See Debugging client JavaScript in Visual Studio 2005.

查看更多
SAY GOODBYE
3楼-- · 2019-01-25 08:56

TechRepublic has a good walk through - see Visual Studio 2008 simplifies JavaScript debugging.

查看更多
仙女界的扛把子
4楼-- · 2019-01-25 09:00

In Internet Explorer, select View -> Script Debugger -> Open. That should do it.

查看更多
何必那么认真
5楼-- · 2019-01-25 09:03

Visual Studio 2008 ASP.NET projects has debugging enabled by default. You can set breakpoints within your .js file while the website/web app project is run in the ASP.NET debug server.

查看更多
放我归山
6楼-- · 2019-01-25 09:05

I usually use Firebug to deal with debugging JS.

Unless you need to debug in IE, there's no need to stop using Firebug. It works with JavaScript in ASP.NET pages just as well as it does with any other type of page.

Visual Studio's JavaScript debugging is alright, but really cannot compete with the full range of client-side information that Firebug aggregates.

查看更多
乱世女痞
7楼-- · 2019-01-25 09:07

Usually you know where you are having problems, so you can set a breakpoint in your JavaScript code by placing the keyword "debugger;" on a line in your JavaScript code (obviously without the quotes) to set a breakpoint.

When you get to it in Internet Explorer, it will ask you if you want to debug and prompt you to choose a debugger from a list, hopefully you will see Visual Studio in that list (both a new instance as well as your currently-running instance) - if you are using Firefox with Firebug, it will automatically stop execution on that line and you will be within the Firebug debugger, not Visual Studio.

You will want to do the following to setup Internet Explorer for doing this - from within Internet Explorer, follow this menu path: Tools > Internet Options > Advanced Tab > Uncheck the "Disable Script Debugging" options.

查看更多
登录 后发表回答