I am not experienced in developing web apps with NetBeans.
I created an HTML5 project with existing sources (some HTML, JS and CSS files), the import seems to be OK, but I didn't manage to debug JavaScript code, because the "Debug project", "Debug file" and "Debug test file" menu items are always disabled.
What have I missed?
PS.: I downloaded a fresh version in November 2013.
HTML5 project is always debugging and running at the same time if you run it in any browser with NetBeans connector (check the browser switcher in toolbar). So once you run project/file, if some breakpoint should be hit, it will be. Therefore debug action is not enabled for HTML5 project, because it is the same as Run action.
Basically it means you can debug JS in Chrome with NetBeans Connector, Embedded browser in IDE, Chrome on Android, Safari on iOS...
I also ran into issues when trying to debug JavaScript in a PHP project. I was using Chrome as my browser and had confirmed that the Netbeans Connector extension was installed and working in Chrome.
I could debug PHP without any issues. I could create a separate HTML5/JavaScript project and debug JavaScript without any problem. However, when I tried to set breakpoints on JavaScript code that was embedded in tags within the PHP file, I would get the little 'broken' breakpoints that everyone else references. When I selected the option to debug project, I could debug the PHP code, but the JavaScript breakpoints were never hit.
The change that I made that finally (for me) caused the JavaScript breakpoints to be hit so I could step through code using the Netbeans debugger was to remove the Javascript from the file containing the PHP/HTML code and place the JavaScript in a separate file that only contained JavaScript via a within the PHP file. Magically, I could debug both JavaScript and PHP within the same debugging session without any extra setup.
Of course, one alternative is to use the debugger within the browser, such as Chrome developer tools, but I really wanted to be able to debug everything from within the same Netbeans environment. Works like a charm now.
Never used the JavaScript debugger myself but you find here a tutorial if it has to be the Netbeans debugger. As an alternative I can recommend the JavaScript debugger from Firebug.
Use the Chrome debugger once the page is loaded in the browser.
When you end up solving cross browser compatibility you'll have to use particular browser console/debugger implementation (which may not be fancy). Before that enjoy in ChromeDevTools or FireBug :)
Related
I recently upgraded from VS 2017 to VS 2019.
In VS 2017, when running an asp.net application locally, using Chrome, I could put a breakpoint in javascript code and the debugger would stop on the breakpoint. This no longer works in Visual Studio 2019.
What do I need to do to enable javascript debugging in Visual Studio 2019 using Chrome? I would like to be able to put breakpoints in javascript files and have them hit.
Here is my setup.
I've enabled Javascript debugging.
I put a breakpoint in my Javscript code. This breakpoint is in a *.js file (not inside a Razor view).
The breakpoint is ignored. Visual Studio very courteously shows me a tooltip telling me the breakpoint will be ignored.
It should work in VS2019+Chrome.(I just checked this in several machines)
This is not one issue can be resolved directly since many factors can cause this behavior, you can follow suggestions below to check if it helps:
1.Update your VS2019 to latest 16.3.7, update your chrome browser to latest 78.0.3904.87
2.Delete the bin and obj folders in your project directory => then close and restart VS => open that project and do a clean rebuild
3.Make sure you're in debug project mode, right-click your web project=>Set as StartUp project
Also, sometimes we need to wait for several seconds before the debug session starts successfully.(I once met same popup, then after several seconds it disappeared and everything worked)
Hope it helps :)
Besides enabling JavaScript debugging in Visual Studio, please ensure that minification is off. (Turn off bundling/minification while debugging in WebForms)
If your page contains Razor syntax, the breakpoints won't work.
Instead add the debugger; statement into the script as a breakpoint.
Then again, the debugger statement had failed to work earlier this year. It only works at top level, means before the page is completely rendered. It will not work if I put the debugger statement into $(document).ready()
So my work around now is to put my javascript in a separate .js file without any Razor syntax.
The good old console.log works for me as nothing suggested as above answers are working at all. Anyway it is what it is amidst the frustration for VS, nothing new about that.
If your Javascript is in a Razor file it will not work.
I have been struggling with this for ages and getting by with console.log.
But just now I moved the js into an external file and bingo it works.
I am using latest VS 16.11.5 and Chrome in a .Net 5 project with Razor pages.
I'm trying to debug some Javascript code inside a JSP page in a web app (Servlets, JSP and JavaScript) I'm working on. In order to be able to debug it I understand I need to check the Debug Web Application (Client side JavaScript) option under Debug section in the Project Properties window.
The problem is I don't have any Debug section in the Project Properties window. I also don't have the JavaScript Libraries section, but I'm not sure whether it's related or not.
What I'm looking for is what is shown here.
Just to be clear, what I need is to be able to debug JavaScript, so if there's a different solution for doing this I would be more than happy to here about it.
If its worth anything I can put breakpoints inside JavaScript, its just that I cannot see any values of variables.
Thanks,
Alon
[EDIT:] As ladar kindly pointed out, the JavaScript debugger was dropped from Netbeans in previous versions (It seems like in version 6.9). As an alternative I use Firebug now.
What version of NetBeans are you using? Javascript debugger was dropped in recent versions (as far as I know 7.0 and newer doesn't support it). So because there is no js debugger, this screenshot is not there because it will always debug server side code
I am writing in javascript for windows (and also in wsf using javascript and vbscript) a desktop script not for internet and not using any explorer.
I need tool for debugging (free one).
Does someone can recommend on one ?
Thanks
I'm assuming you are creating WSH scripts based on your description. In order to debug WSH JavaScripts, start your script with wscript.exe /d path to WSH file after that, whenever an exception is going to occur, you are going to be presented with a choice to debug the script with Visual Studio or Microsoft Script Debugger (free). If you just want to step through the code start your script with wscript.exe /d /x path to WSH file this will cause an exception right at the begging of your script execution.
More information here
Aptana Studio is a great Eclipse extension and can also debug Javascript
I've heard Firebug Lite could do this? That's probably not what you're looking for still.
From the question, it sounds like you are trying to make an AJAX app that perhaps loads from local javascript + HTML.
That said, if it is OK to use Firefox as the web client, you might try Firebug. It is an excellent javascript debugger. It lets you do usual step / breakpoint things, inspect variables, and display the current page as a DOM model to help see what your jQuery (or Prototype, in my case) queries will find.
I encountered a strange problem today. Whenever i put a breakpoint in one of my js files, the breakpoint is not hit.
I use Visual Studio 2005 in combination with TFS.
In ie the disable script options are both disabled.
The only thing that changed is that I installed Visual Basic 6 for an old project, but I don't see how that would impact debugging via Visual Studio 2005.
Did anyone had this problem before, or better does anyone know a solution?
thx.
In order for Javascript debugging to work the Visual Studio needs to be attached as a debugger to the IE process and it needs to be able to resolve the phyiscal path of the javascript file with the URL of the same script loaded in IE.
Have you checked that when you start debugging in VS that it actually attaches to the IE process that gets spun up?
Customizer your toolbar, on the commands tab select the debug category then find the "Script Explorer" command, drag it to a tool bar. Close the dialog.
Using script explorer you should be able to find the script that ought to have the break point on. Ordinarily VS is able to combine the root path it specifies for the developer web server with the physical JS file path in order to determine what its URL would look like from the browsers perspective, it can then novate the break point from the physical file to the script loaded in the browser.
you can also use a debugger; statement in your js. IE will then prompt you to debug the script file and should give you the option to debug in Visual studio 2005/2008 if you have them.
Explained here
A collegue found the issue: the Just in time debugger was only set to handle Managed and native code, and no scripting.
I just had to re-set it in the visual studio options pane.
I'm trying to debug javascript code just by adding a breakpoint in VS2008, but the debugger's not stopping. Do I have to do some special setup in order to enable javascript debugging? Or does the code have to be in a separate js file?
Did you uncheck the checkboxes in the settings
Tools-->Internet Options-->Advanced-->Browsing [heading]-->Uncheck "Disable Script Debugging (Internet Explorer)" and Uncheck "Disable Script Debugging (Other)"
Sometimes you need to restart the browser to get VS2008 to recognize that it has made some changes.
Have you tried to stick the "debugger;" keyword into your JavaScript file? This usually never fails me.
If you have IE8, you can debug right in the browser itself.
Any particular browser? Mainly it works with IE, and needs script debugging enabled in the IE internet options (advanced => browsing).
I don't know about VS2008, but I know I've never been able to get the debugger to stop on a breakpoint in an aspx (as opposed to a linked js file).
If you are not running this in a project, but just debugging on the fly, be sure to attach to the browsers' process.
I know it's not what you asked, but I gotta plug Firebug for JS debugging, including breakpoints, watch statements, stepping, and a live JS console.