如何在Visual Studio 2005中调试JavaScript?

时间:2022-09-26 03:33:42

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?

我刚刚在Stack Overflow问题中看到了这个提到最好的WYSIWYG CSS编辑器并且不知道它可以完成。我是Visual Studio的新手,你怎么做的?

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.

是否有单独的JavaScript调试器?我知道如何使用代码隐藏页面...我通常使用Firebug来处理调试JavaScript代码。

I'm using Visual Studio 2005.

我正在使用Visual Studio 2005。

11 个解决方案

#1


6  

I prefer using Firebug for projects I can't use Visual Studio 2008 on.

我更喜欢使用Firebug用于我无法使用Visual Studio 2008的项目。

#2


6  

To debug in Visual Studio 2005, make sure that "disable script debugging" is unchecked. Then load your webpage in Internet Explorer. From the debug menu inside of Visual Studio 2005, select "Attach to process" and pick the instance of Internet Explorer that has your web page loaded.

要在Visual Studio 2005中进行调试,请确保未选中“禁用脚本调试”。然后在Internet Explorer中加载您的网页。从Visual Studio 2005内部的调试菜单中,选择“附加到进程”并选择已加载网页的Internet Explorer实例。

Alternatively, the Firebug team has been working on a "lite" version that you can include either as a script in your page or by launching it via a bookmarklet from your browser. It doesn't provide the full debugger that Firebug does, but it gives you a console and a command line from which you can inspect variables and log things to the console.

或者,Firebug团队一直致力于“精简”版本,您可以将其作为脚本添加到页面中,也可以通过浏览器中的书签启动它。它没有提供Firebug的完整调试器,但它提供了一个控制台和一个命令行,您可以从中检查变量并将事物记录到控制台。

#3


2  

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.

Visual Studio 2008 ASP.NET项目默认启用调试。在ASP.NET调试服务器中运行网站/ Web应用程序项目时,可以在.js文件中设置断点。

#4


2  

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

TechRepublic有一个很好的演练 - 请参阅Visual Studio 2008简化JavaScript调试。

#5


1  

Just make sure you have 'Disable Script Debugging' unchecked, and just hit F5 to start debugging in VS2005 or 2008.

只需确保未选中“禁用脚本调试”,然后点击F5即可在VS2005或2008中开始调试。

I would also note that if you have your JavaScript inside the .aspx page you will have to find it via the script explore. However if you have it in a separate .js file you can just put a break point on it like you would any .cs file.

我还要注意,如果你在.aspx页面中有JavaScript,你必须通过脚本探索找到它。但是,如果你将它放在一个单独的.js文件中,你可以像使用任何.cs文件一样在它上面设置一个断点。

#6


0  

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

在Internet Explorer中,选择“查看” - >“脚本调试程序” - >“打开”。应该这样做。

#7


0  

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.

通常您知道自己遇到问题的位置,因此您可以通过放置关键字“debugger”来在JavaScript代码中设置断点。在JavaScript代码中的一行(显然没有引号)来设置断点。

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.

当您在Internet Explorer中访问它时,它会询问您是否要调试并提示您从列表中选择调试器,希望您将在该列表中看到Visual Studio(既包括新实例也包括当前正在运行的实例)实例) - 如果你使用Firefox和Firebug,它将自动停止在该行上执行,你将在Firebug调试器内,而不是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.

您需要执行以下操作来设置Internet Explorer以执行此操作 - 从Internet Explorer中,按照以下菜单路径:工具> Internet选项>高级选项卡>取消选中“禁用脚本调试”选项。

#8


0  

You can set a breakpoint within JavaScript in Visual Studio 2005, but in addition to debugging needing to be enabled in Internet Explorer, you can only set the breakpoint in a .js file. You cannot debug any inline JavaScript code.

您可以在Visual Studio 2005中的JavaScript中设置断点,但除了需要在Internet Explorer中启用调试之外,您只能在.js文件中设置断点。您无法调试任何内联JavaScript代码。

I also sometimes have problems when trying to debug my JavaScript code when using the attach process method to go into debugging. I will normally use the "Start debugging" green arrow. You will know that your code will stop at the breakpoint in your .js file if the breakpoint icon (Burgandy Circle by default) is filled in. If it's not filled in, you will never stop there.

在使用attach process方法进行调试时尝试调试JavaScript代码时,我有时也会遇到问题。我通常会使用“开始调试”绿色箭头。如果填写了断点图标(默认情况下为Burgandy Circle),您将知道您的代码将停在.js文件的断点处。如果没有填写,您将永远不会停在那里。

Finally, make sure you have debugging enabled in your ASP.NET configuration settings.

最后,确保在ASP.NET配置设置中启用了调试。

#9


0  

Debugging client JavaScript code in Visual Studio 2005:

在Visual Studio 2005中调试客户端JavaScript代码:

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

将以下代码添加到JavaScript代码的开头:

debugger

See Debugging client JavaScript in Visual Studio 2005.

请参阅在Visual Studio 2005中调试客户端JavaScript。

#10


0  

Yeah using Microsoft Script Editor is a an option if you have Office XP or Office 2003 installed. In IE uncheck Disable Script debugging (Internet Explorer) and Disable Script debugging (Other).

是否使用Microsoft脚本编辑器是一个选项,如果您安装了Office XP或Office 2003。在IE中,取消选中“禁用脚本调试(Internet Explorer)”和“禁用脚本调试(其他)”。

Restart IE. In View menu you will have a new item, "script debugging", choose open. You will be given a choice of VS2005 or New instance of Microsoft Script Editor, choose that and give it a go.

重启IE。在“查看”菜单中,您将有一个新项目“脚本调试”,选择打开。您将可以选择VS2005或Microsoft脚本编辑器的新实例,选择它并开始使用。

Edit: try this link for a tutorial

编辑:尝试此链接获取教程

#11


0  

I usually use Firebug to deal with debugging JS.

我通常使用Firebug来处理调试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.

除非您需要在IE中进行调试,否则无需停止使用Firebug。它与ASP.NET页面中的JavaScript一起使用,就像它与任何其他类型的页面一样。

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

Visual Studio的JavaScript调试没问题,但实际上无法与Firebug聚合的全部客户端信息竞争。

#1


6  

I prefer using Firebug for projects I can't use Visual Studio 2008 on.

我更喜欢使用Firebug用于我无法使用Visual Studio 2008的项目。

#2


6  

To debug in Visual Studio 2005, make sure that "disable script debugging" is unchecked. Then load your webpage in Internet Explorer. From the debug menu inside of Visual Studio 2005, select "Attach to process" and pick the instance of Internet Explorer that has your web page loaded.

要在Visual Studio 2005中进行调试,请确保未选中“禁用脚本调试”。然后在Internet Explorer中加载您的网页。从Visual Studio 2005内部的调试菜单中,选择“附加到进程”并选择已加载网页的Internet Explorer实例。

Alternatively, the Firebug team has been working on a "lite" version that you can include either as a script in your page or by launching it via a bookmarklet from your browser. It doesn't provide the full debugger that Firebug does, but it gives you a console and a command line from which you can inspect variables and log things to the console.

或者,Firebug团队一直致力于“精简”版本,您可以将其作为脚本添加到页面中,也可以通过浏览器中的书签启动它。它没有提供Firebug的完整调试器,但它提供了一个控制台和一个命令行,您可以从中检查变量并将事物记录到控制台。

#3


2  

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.

Visual Studio 2008 ASP.NET项目默认启用调试。在ASP.NET调试服务器中运行网站/ Web应用程序项目时,可以在.js文件中设置断点。

#4


2  

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

TechRepublic有一个很好的演练 - 请参阅Visual Studio 2008简化JavaScript调试。

#5


1  

Just make sure you have 'Disable Script Debugging' unchecked, and just hit F5 to start debugging in VS2005 or 2008.

只需确保未选中“禁用脚本调试”,然后点击F5即可在VS2005或2008中开始调试。

I would also note that if you have your JavaScript inside the .aspx page you will have to find it via the script explore. However if you have it in a separate .js file you can just put a break point on it like you would any .cs file.

我还要注意,如果你在.aspx页面中有JavaScript,你必须通过脚本探索找到它。但是,如果你将它放在一个单独的.js文件中,你可以像使用任何.cs文件一样在它上面设置一个断点。

#6


0  

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

在Internet Explorer中,选择“查看” - >“脚本调试程序” - >“打开”。应该这样做。

#7


0  

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.

通常您知道自己遇到问题的位置,因此您可以通过放置关键字“debugger”来在JavaScript代码中设置断点。在JavaScript代码中的一行(显然没有引号)来设置断点。

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.

当您在Internet Explorer中访问它时,它会询问您是否要调试并提示您从列表中选择调试器,希望您将在该列表中看到Visual Studio(既包括新实例也包括当前正在运行的实例)实例) - 如果你使用Firefox和Firebug,它将自动停止在该行上执行,你将在Firebug调试器内,而不是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.

您需要执行以下操作来设置Internet Explorer以执行此操作 - 从Internet Explorer中,按照以下菜单路径:工具> Internet选项>高级选项卡>取消选中“禁用脚本调试”选项。

#8


0  

You can set a breakpoint within JavaScript in Visual Studio 2005, but in addition to debugging needing to be enabled in Internet Explorer, you can only set the breakpoint in a .js file. You cannot debug any inline JavaScript code.

您可以在Visual Studio 2005中的JavaScript中设置断点,但除了需要在Internet Explorer中启用调试之外,您只能在.js文件中设置断点。您无法调试任何内联JavaScript代码。

I also sometimes have problems when trying to debug my JavaScript code when using the attach process method to go into debugging. I will normally use the "Start debugging" green arrow. You will know that your code will stop at the breakpoint in your .js file if the breakpoint icon (Burgandy Circle by default) is filled in. If it's not filled in, you will never stop there.

在使用attach process方法进行调试时尝试调试JavaScript代码时,我有时也会遇到问题。我通常会使用“开始调试”绿色箭头。如果填写了断点图标(默认情况下为Burgandy Circle),您将知道您的代码将停在.js文件的断点处。如果没有填写,您将永远不会停在那里。

Finally, make sure you have debugging enabled in your ASP.NET configuration settings.

最后,确保在ASP.NET配置设置中启用了调试。

#9


0  

Debugging client JavaScript code in Visual Studio 2005:

在Visual Studio 2005中调试客户端JavaScript代码:

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

将以下代码添加到JavaScript代码的开头:

debugger

See Debugging client JavaScript in Visual Studio 2005.

请参阅在Visual Studio 2005中调试客户端JavaScript。

#10


0  

Yeah using Microsoft Script Editor is a an option if you have Office XP or Office 2003 installed. In IE uncheck Disable Script debugging (Internet Explorer) and Disable Script debugging (Other).

是否使用Microsoft脚本编辑器是一个选项,如果您安装了Office XP或Office 2003。在IE中,取消选中“禁用脚本调试(Internet Explorer)”和“禁用脚本调试(其他)”。

Restart IE. In View menu you will have a new item, "script debugging", choose open. You will be given a choice of VS2005 or New instance of Microsoft Script Editor, choose that and give it a go.

重启IE。在“查看”菜单中,您将有一个新项目“脚本调试”,选择打开。您将可以选择VS2005或Microsoft脚本编辑器的新实例,选择它并开始使用。

Edit: try this link for a tutorial

编辑:尝试此链接获取教程

#11


0  

I usually use Firebug to deal with debugging JS.

我通常使用Firebug来处理调试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.

除非您需要在IE中进行调试,否则无需停止使用Firebug。它与ASP.NET页面中的JavaScript一起使用,就像它与任何其他类型的页面一样。

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

Visual Studio的JavaScript调试没问题,但实际上无法与Firebug聚合的全部客户端信息竞争。