Problems setting breakpoints for JavaScript in Visual Studio 2008 - javascript

I'm trying to debug JavaScript in Visual Studio 2008. I use ASP.NET MVC, jQuery, and jQueryUI.
I can set a breakpoint, but when I start debugging Visual Studio changes the breakpoint icon to one with a warning. 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.
My JavaScript code is very simple and not dynamically generated. What am I missing?

Try typing the code "debugger;" in the place where you want the breakpoint. When IE hits that line, it should stop whether a debugger is attached or not.
Visual Studio will do what you described during startup, since the code isn't being run yet. 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.)
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.

Related

Chrome Developer Tools keeps breaking where no breakpoints are set

When debugging JavaScript code using Chrome Developer Tools the debugger pauses on code where breakpoints are not set. I don't have the Pause on exceptions feature enabled, and there definitely are not breakpoints set (see attached image).
I asked a similar question before which was helpful but didn't quite solve this issue (previously I had the Pause on exceptions enabled). In the example below I swapped out the minified version of kendo.all.min.js for the unminified version, which allows me to see where the script execution is being paused, but I don't know why it is being paused. This happens a lot with jquery.min.js too.
I fixed my breakpoints problem by clicking the "Restore defaults and reload" button located in the “Settings” section. To find the button: In Developer Tools click the cogged wheel next to the top right three vertical dots. (Note: If using older versions of Google Chrome, click on the top right three vertical dots and then select “Settings F1”). The button “Restore defaults and reload” is at the bottom right.
Also note that it really restores defaults - you lose all previously saved breakpoints and any files you have open in Developer Tools will be closed.
I got this solution from: Chrome javascript debugger breakpoints don't do anything?
Accepted answer to Import/export Chrome devtools breakpoints & settings between computers reminded me to check "devtools-on-devtools" and in the DevTools' inner Application Local Storage remove the faulty element(s) of the JSON list value for key breakpoints to fix my same issue without resetting everything.
Later it happened again, so I wrote this console snippet:
((stores, matchKey, removeMatchingRegExp, dryRun)=>{for(let store of stores){
let r = JSON.parse(localStorage[store]), l = r.length;
r = r.filter(b=>!b[matchKey].match(removeMatchingRegExp));
if(!dryRun) localStorage[store] = JSON.stringify(r);
console.log(`${dryRun ? 'Would' : 'Did'} remove ${l - r.length} entries from ${store}:`, r)}; return 'OK'})
(['breakpoints', 'domBreakpoints'], 'url',
new RegExp('^https?://example.com/script.js$'), true)
Note:
Provided without warranty: Use at own risk. Backup your data.
Edit it - at least the RegExp argument - to suite your needs.
The last-most boolean should be false to disable dryRun.
Outer DevTools must be reopened for effect.
I was able to resolve this by updating Chrome. I don't think the version matters, just the process of updating resets all of the breakpoints that have been stored in the cache.
F8 has two functionalitys. 1. Skip ot next Breakpoint, 2.stop wherever the Browser is executing code. This works even if you have no breakpoint set. For example spamming F8 when you forgot to deactivate breakpoints might cause the browser to stop anywhere.
When you go to the debugger shortcuts you can see that F8 has the functionality to Pause / Continue. But it sadly seems like you can't split them on two different keybinds.
Since I know this feature I never ran into this "bug" anymore.
I'm posting this answer in case it will help someone who, like me, missed an important clue as to the cause of the phantom breakpoint behavior. In my case, it was "user error" --mine. The root cause was a forgotten "debugger;" statement in a JavaScript file that was itself generated from TypeScript. I had removed the debugger; statement from TypeScript locally, run and tested without issue from localhost. But I had pushed the version with the statement to remote and it built and released to our dev site with the statement present. The dev site build excludes the TypeScript source files. When the debugger statement was hit, Chrome tried to load the .ts source and displayed "Could not load content..." I just assumed it was at a breakpoint (I'd set many during testing). And when I saw "No breakpoint" I assumed Chrome was experiencing the issue addressed in this thread. If I'd bothered to look in the Call Stack trace, I would have seen the source code line in the .ts file and pretty quickly figured it out. Here's a screenshot:
just disable the cache and reload the page, the breakpoints will show up again

Unable to debug javascript in Visual studio

I tried to debug my javascript but it doesn't fires the breakpoint.
I am using IE8 and VS2010.
On trying to add
debugger;
an error occurs like;
An unhandled exception (script breakpoint) occured in iexplorer.exe
Possible debuggers:
I found that Tools-->Debugging-->Just In Time-->script is unchecked.
I checked it and saved....It remains unchecked....
I repaired my visual studio still issue continues...
The issue occures after i had installed VS2012
I know it's late, but I found out why this happened to me. I had
debugger;
scattered throughout my javascript file because both IE and Chrome would not hit my breakpoints.
When using IE and hitting F12 for Developer Tools, the code breaks on the debugger lines but the Windows pop-up did not open. Hitting "Continue" in the debugger window executed the code normally.
Hope this helps
Have a look at this so answer, seems you are not doing all the steps required
I had a similar problem. I renamed default.html to index.html and lost script debugging.
Go to the project properties web tab. Make sure 'Start Action' is set to 'Specific Page' and your start page is selected in the text box.
I believe its too late to reply.
But deploy your solution in Visual Studio in RELEASE MODE and NOT IN DEBUG MODE.
This solution solved my problem.
Go to Tools => Options = > Debugging => Just-In-Time and uncheck Script to sto

firebug script panel not showing any scripts

I am trying to debug my javascript & jQuery and step through it using firebug.
I am running my code on an Apache server (2.4) on a windows machine.
I used the firefox browser version 18.
When i go to run my code, I can't see my javascript (external file) in the scripts panel.
I see the linked jQuery library on the panel but I dont see my javascript code.
On the Firebug, the scripts are clearly linked in the HTML panel. But on the script panel, only the jQuery.js is visible. i would post a screen shot but i dont have enough reputation right now.
I dont know what is going on and what i have to do in order to be able to step through my javascript code.
UPDATE
I placed the "debugger" on my javascript code but it still not showing on the 'script panel'.
debugger;
$(document).ready(function () {
var email_default = "Enter your email address...";
$(':input[type="email"]').val(email_default).on('focus', function () {
if ($(this).val() == email_default) {
$(this).val(' ');
}
});
I also tried to do a browser refresh, disable and re-enable all the firebug panels- but it still won't show my external javascript. I had also double checked my file location & directories to make sure i am linking it correctly.
If Firebug (or other browser developer tools) doesn't show a JavaScript in the list of available scripts, this means it has a syntax error.
In that case you need to switch to the Console panel and check there for the error.
Notes:
As mentioned in a related answer, there can also be other reasons why there are no scripts shown in the list:
Since Firefox 49.0 and Firebug 2.0.18 the Script panel is completely broken. This is due to some internal Firefox API changes. And because Firebug is officially discontinued, this unfortunately won't get fixed anymore.
There was also a bug in Firebug 2.0.11 (and below) in combination with Firefox 39.0 causing this problem. This bug got filed as issue 7918 and fixed for version 2.0.12.
It happens when the Script panel is enabled and you close Firebug and then reopen it.

Step Through HTML in VS 2010?

I'm wondering if it is possible to step through HTML and JavaScript Code in VS2010 ? I have a project in which I have an HTML file with Javascript inside it...I can't set a breakpoint on the HTML and although I can set a breakpoint on the Javascript it will not pause when I run the project.
Thanks
you can't debug HTML. If you want to debug javascript code that is embedded in the HTML, add a line
debugger;
inside the script tag. The browser will stop and let you debug it from there
As far as i know, you can't set breakpoints in/on HTML code, why would you. You can step through JavaScript code in IE, if you allow debugging of client scripts in the internet options of IE. For any other browser you will need some other JavaScript-debugger, something like Firebug.
If you are sure you have the javascript debugger attached, you can put a simple debugger; statement in your js which will cause it to break. You will have to have script debugging turned on an VS attached to your IE process. You could also use the IE Dev Tools JS debugger.

How do I get rid of phantom breakpoints in javascript files in Aptana?

I have a small project containing 1 HTML file and 4 JavaScript files. Recently, while debugging my scripts using the Aptana Firefox plugin, I managed to introduce what I'll call a 'phantom' breakpoint into my project.
The breakpoint itself is tied to a particular line, not a particular expression or call. For example, if the 'phantom' breakpoint is affecting line 79 and I have only a comment on line 79, the breakpoint is never hit. But, if I have a valid JavaScript statement, such as 'var x = 2;' on line 79, the breakpoint will always be hit.
Re-adding the breakpoint on that line and removing using the 'Remove' command in the Breakpoints view does nothing.
Clearing all breakpoints through the 'Run->Remove all breakpoints' option does nothing.
The breakpoint does not show up in the Breakpoints view, and there is no indication in the file that the breakpoint exists.
I have tried deleting my workspace and recreating. Didn't work.
I have tried deleting the project and re-adding the source files. Didn't work.
I have verified that the breakpoint is not an unhandled exception as mentioned in this question.
Does anyone know how to remove these 'phantom' breakpoints from Aptana projects?
Environment:
Windows 7 64-bit
Aptana Studio v2.0.5
Aptana Debugger Firefox plugin v1.6.0
Firebug plugin v1.6.2
Try the following:
Start debugger session from Aptana Studio
Switch to Firefox, open Firebug using status bar icon.
Open Breakpoints tab on right
In it's drop-down menu select "Remove All Breakpoints"
There is one way I found which will get rid of this type of breakpoint is:
Click on firebug icon in the actual page, and select options and click reset all firebug options.
That should take care of this issue.

Categories

Resources