Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using breakpoints to debug Javascript in IE and VS2008

I am not able to use the breakpoint in Studio with Javascript. I'm able to debug if I use the debugger;

I've seen this Breakpoint not hooked up when debugging in VS.Net 2005 question already. I tried the answer and it didn't work.

Looking in the Modules window, V.Mvc.Jobtrakt.PDB is loaded properly, but it points to a temp folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\dbc0c0c5\f64a99b3\assembly\dl3\9de055b3\eb1303b1_9760c901\V.Mvc.Jobtrak.pdb: Symbols loaded.

I would have thought that it would point to: \JobTrak\Website\V.Mvc.Jobtrak\V.Mvc.Jobtrak\obj\Debug ( this is within the project directory)

But regardless of the location I closed VS 2008 and then blew away the temp folder (listed above), the bin and obj folders.

Opened VS 2008 and did a clean. I set a break point in the js and it seemed like it would work now ( The breakpoint was filled in) Started to debug and it never breaks on the breakpoint. Look at the break point and it now is a red circle with a red dot and a warning indicator. Hovering over the breakpoint gives me this useful information: The breakpoint will not currently be hit. The location could not be mapped to a client side script. See help for ASPX Breakpoint mapping. I am not being redirected, the breakpoint is with in a function. blah blah blah this should be working.

So I was wondering if anyone has any ideas? Is anyone able to set breakpoints in VS2008 and have them work?

like image 625
Brad8118 Avatar asked Dec 17 '08 23:12

Brad8118


People also ask

Can you use breakpoints in JavaScript?

Setting BreakpointsIn the debugger window, you can set breakpoints in the JavaScript code. At each breakpoint, JavaScript will stop executing, and let you examine JavaScript values. After examining values, you can resume the execution of code (typically with a play button).


2 Answers

try typing "debugger" in the source where you want to break

like image 196
Greg Dean Avatar answered Nov 08 '22 15:11

Greg Dean


Make sure you are attached to the correct process. For example, once you have your page loaded in IE,

  1. Switch to Visual Studio and go to the Debug menu.
  2. Choose "Attach to Process"
  3. Find iexplore in the list and select it.
  4. Click the "Select..." button.
  5. In the dialog, choose "Debug these code types:" and select only "Script".
  6. Click "OK"
  7. Click "Attach"

See if that helps get you debugging javascript.

like image 21
palehorse Avatar answered Nov 08 '22 14:11

palehorse