Chrome Debugger source file line numbers wrong - javascript

This has been driving me crazy. It just started a few weeks ago. I never had the problem before.
I'm trying to debug a simple issue in the Chrome debugger.
My cshtml source file has a script tag embedded in it with a small script. I used the tag to make Chrome recognize the "source" file:
//# sourceURL=CustomerView.js
I am able set breakpoints and they show the correct line number in the debugger. But they never hit. I add a Debugger line in the script and the chrome debugger breaks but the line number in the call stack is WAY off. There's no way for me to view/walk through the source to debug.
Any insight into this would be very helpful.

Related

IE 11 cannot set breakpoint in javascript file added to HTML page

I have an HTML page that has an embedded javascript file that for some reason or another I cannot debug. I can click on the error line to go to the location in the code but once there I cannot actually set a breakpoint inside the IE 11 debugger. I can however set a breakpoint in the HTML which isn't helpful to me.
I've read similar posts on the topic but they haven't helped. I've unchecked the box that disables script debugging in the IE 11 options.
Does anyone know what could actively prevent the debugging from happening? Even console.log lines aren't making it through...
Thanks.
edit: the exact error I'm getting is SCRIPT1010: Expected identifier on an Object.entries().forEach call that I've already added the necessary polyfills for.

Debugging in-page javascript with Chrome when the html is minified?

The scripts on our website are embedded in the html and everything is minified. Throwing a debugger statement into the javascript to debug doesn't help very much because there's only actually one line of html in the original source. When the source is prettified with Chrome's code prettifier, the debugger points to the wrong line in the code.
How can I debug minified javascript embedded in the html?
One thing that might help is that you can set breakpoints in chrome w/o using the debugger directive directly in code. Simply view the prettified code output in the chrome sources tab, and then double click on the line where you want to add a breakpoint.

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.

javascript not working with IE

My page is working fine with FF , but not working under IE ,
I have a JSP page and a JS file (The error is inside JS File)
I am using IE developer toolbar
Its only showung me the Line number and the character.
Please see the screen shot .
http://www.tiikoni.com/tis/view/?id=3bc4916
MY JSP file is of only 20 lines and JS file is of 200 lines , with many 3rd party JS files included.
How can we debug as i dont have that line number in my JSP FIle and view source doesn't help.
Please help me
Internet Explorer 8 has a built in debugger. You can find instructions for how to use it here JScript Debugger in IE8.
Basically, if you enable this, then you can actually go look at the code and see where the problem is.
The debugger can not only show you the code, but also a snapshot of the variables at the time the error occurs. Using this information, you can further pinpoint the problem.

Problems setting breakpoints for JavaScript in Visual Studio 2008

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.

Categories

Resources