I am using Asp.Net MVC project and using jQuery to code JavaScript. Problem is I am not able to debug JavaScript. I searched for this issue and found a few threads. Basically this one:
Visual Studio 2010 script debugger doesn't work for me
And
The breakpoint will not currently be hit. No symbols have been loaded for this document in a Silverlight application
None of these are currently working for me. I tried to launch my application in Chrome and IE9 but my breakpoint just doesn't get hit.
Can you tell me what is the issue?
Use IE9 with the F12 developer tools, FF5/FireBug and Chrome. They all have good javaScript debuggers. It's a good idea to use all of them.
Related
Currently I am debugging my JavaScript using Firebug for Firefox. Is there anyway to debug javascript in Visual Studio 2010? The JavaScript isn't part of any Visual Studio project, it's just a .js file that will be linked to a static HTML page (it's to debug school assignments).
I did try searching and the results weren't any more recent than around a year ago. I'm hoping something has changed or there is a better workflow than notepad++ for HTML/JavaScript and Firebug for debugging.
Use the JavaScript debugger keyword in IE.
function onClickRow(detailUrl) {
debugger;
}
When run your page in IE, a debug window will pop up, then select Visual Studio 11.
To use debug in Internet Explorer, you need perform these steps:
enable script debugging in IE (go to Internet options->advanced->browsing and uncheck 'Disable script debugging')
select view->external script debugger->break on next statement
When next javascript statement will be reached, IE will show standard windows debugger selection dialog, when you can select instance of visual studio.
Update:
With visual studio you can attach to browser process(e.g. iexplore.exe) and then debug
This question gets a lot of views so for the sake of completeness I just wanted to mention that I've been using Chrome Developer Tools for a while now. It's been working great for me and is what I recommend now when people ask me this same question.
Yes, but only in IE. Basically just create a web-page project and hit run. It'll launch IE in debugger mode.
disable option from Internet Options like here : http://www.mayanksrivastava.com/2010/02/debugging-java-script-in-visual-studio.html
If you installed VS 2012 and then uninstalled it, you may need to Re-Install Visual Studio 2010.
Error you may get when trying to debug JavaScript:
---------------------------
Microsoft Visual Studio
---------------------------
Unable to attach to the crashing process. The correct version of pdm.dll is not registered. Repair your Visual Studio 2010 installation, or run 'regsvr32.exe "%CommonProgramFiles%\Microsoft Shared\VS7Debug\pdm.dll"'.
---------------------------
OK
---------------------------
If you want to try giving it a shot in IE, I posted about using the js debugger here:
jQuery/Ajax content not appearing/loading in Explorer
I am using Visual Web Developer 2008.I have debug my javascript at localhost by adding a breakpoint/debugger in js file.It works perfectly in IE8 before.
This nice debug function is broken, after I try a developer tools(Press F12 in IE8).
Firebug is my best tool for this.
I am talking of course for the firefox addon
Firebug is great (+1). However, the debugger in IE8 also works fine. I never use the VS debugger. If you're already using IE8 developer tools, just debug there instead of in VWD.
Does Dreamweaver CS 3 have a JavaScript debugger?
The only information on anything close is that it says I need to click on the
'preview/debug in browser' button which does open the page, but no debugging ever happens when the page has an error. I also see no way to set breakpoints or walk through the code.
MS Visual Web Developer (Visual Studio Express - which is free) has a debugger that you can attach to a process. So even if you are not developing in it, you can debug the JavaScript in any browser. It also has a very rich variable watch that allows you to drill down through all the decendants of an object for its respective values. I was hoping that Dreamweaver could at least match Visual Web Developer...
What is the experience using the Visual Studio debugger tools with non-Internet Explorer browsers?
Dreamweaver has no effective built-in debugger.
Firebug works great with non-Internet Explorer browsers
Visual Studio tools work great with ID browsers
What is the one that works well across the board?
Debuggers are specific to a particular interpreter/compiler, not to a language. The same language - in this case, JavaScript - can have more than one interpreter/compiler. In particular, each browser has their own.
So to debug JavaScript in Internet Explorer, you need an Internet Explorer debugger - either the one built into Internet Explorer, or one of the Visual Studio flavours. To debug JavaScript in Chrome, use Chrome's debugger. To debug JavaScript in Firefox, use Firebug. (And so on.)
There is nothing native to Dreamweaver that handles debugging JavaScript, but there are several other options out there for free.
The Firebug add-on for Firefox allows you to set breakpoints and step through JavaScript. Download and play with that, and you should find what you need. Here is a brief tutorial hitting on your points: Debug Javascript with Firebug
I solved most JavaScript problems using the Error Console in FireFox. I never got Dreamweaver's to work.
I agree with CheGueVerra, defenitively the best debugger is the "error console" in Firefox. If you want to make it even better, just download the Firefox Add-on Console². All you need to debug JavaScript code is there.
You can also use Firebug, which is in my opinion the best JavaScript debugger for Firefox even if there are still some issues sometimes (refer to my post a few days ago, Stack Overflow question Firebug debugger not working in Firefox 3.x?).
I assume you're looking for something where you can attach breakpoints and such... Well, without echoing the others (this can be done in Firebug), do try Aptana Studio. It can be run like a plugin on Eclipse and can be used to debug JavaScript.
How can I debug JavaScript in Eclipse. I am using Eclipse 3.2.1. Everytime I click on the side it gives the option for adding bookmark but no break point.
Could anyone assist me on this?
In 2015, there are at least six choices for JavaScript debugging in Eclipse:
New since Eclipse 3.7: JavaScript Development Tools debugging support. The incubation part lists CrossFire support. That means, one can use Firefox + Firebug as page viewer without any Java code changes.
New since October 2012: VJET JavaScript IDE
Ajax Tools Framework
Aptana provides JavaScript debugging capabilities.
The commercial MyEclipse IDE also has JavaScript debugging support
From the same stable as MyEclipse, the Webclipse plug-in has the same JavaScript debugging technology.
Adding to the above, here are a couple of videos which focus on "debugging JavaScript using eclipse"
Debugging JavaScript using Eclipse and Chrome Tools
Debugging JavaScript using Eclipse and CrossFire (with FB)
Outdated
The Google Chrome Developer Tools for Java allow debugging using Chrome.
I don't believe Eclipse has a JavaScript debugger - those breakpoints are for Java code (I'm guessing you are editing a JSP file?)
Use Firebug to debug Javascript code, it's an excellent add-on that all web developers should have in their toolbox.
I'm not a 100% sure but I think Aptana let's you do that.
I tried to get aptana running on my ubuntu 10.4. Unfortunately I didn't succeed. Chrome on the other hand, has an eclipse plugin that lets you debug javascript that's running in a chrome instance. Works very well.
YOu'll have to install the eclipse plugin you'll find here:
http://code.google.com/p/chromedevtools/
Set Breakpoints in the javascript sources you edit in eclipse and browser your page in chrome. As soon as a javascript breakpoint is hit, the eclipse debugger halts and lets you step into, step over, browse the variables etc. Very nice!
JavaScript is executed in the browser, which is pretty far removed from Eclipse. Eclipse would have to somehow hook into the browser's JavaScript engine to debug it. Therefore there's no built-in debugging of JavaScript via Eclipse, since JS isn't really its main focus anyways.
However, there are plug-ins which you can install to do JavaScript debugging. I believe the main one is the AJAX Toolkit Framework (ATF). It embeds a Mozilla browser in Eclipse in order to do its debugging, so it won't be able to handle cross-browser complications that typically arise when writing JavaScript, but it will certainly help.
Use the debugging tools supported by the browser. As mentioned above
Firebug for Firefox
Chrome Developer Tools from Chrome
IE Developer for IE.
That way you can detect cross-browser issues. To help reduce the cross-browser issues, use a javascript framework ie jQuery, YUI, moo tools, etc.
Below is a screenshot (javascript-debug.png) of what it looks lime in Firebug.
1) hit 'F12'
2) click the 'Script' tab and 'enable it' (if you are already on your page - hit 'F5' to re-load)
3) next to the 'All' drop down, there will be another dropdown to the right. Select your javascript file from that dropdown.
In the screenshot, I've set a break-point at line 42 by 'left-mouse-click'. This will enable you to break, inspect, watch, etc.
It's possible to debug JavaScript by setting breakpoints in Eclipse using the AJAX Tools Framework.
MyEclipse (eclipse based, subscription required) and Webclipse (an eclipse plug-in, currently free), from my company, Genuitec, have newly engineered (as of 2015) JavaScript debugging built in:
You can debug both generic web applications and Node.js files.
For Node.js there is Nodeclipse 0.2 with some bug fixes for chromedevtools
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.
I prefer using Firebug for projects I can't use Visual Studio 2008 on.
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.
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.
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.
TechRepublic has a good walk through - see Visual Studio 2008 simplifies JavaScript debugging.
Just make sure you have 'Disable Script Debugging' unchecked, and just hit F5 to start debugging in VS2005 or 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.
In Internet Explorer, select View -> Script Debugger -> Open. That should do it.
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.
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.
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.
Finally, make sure you have debugging enabled in your ASP.NET configuration settings.
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.
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).
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.
Edit: try this link for a tutorial
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.