0

So the scenario is: there are a lot of javascript code in a page. If I click a button, it will trigger a certain piece of the code. But I'm not the author of the page so I don't know which file contains that piece nor which function. Is there a way to set such a breakpoint so that I can check the code when it gets executed?

EDIT: Thanks for the comments. I found where exactly my problem was. That page calls a method in a library every second so chrome always steps in that method instead of what I really want, which confused me as I thought it wasn't debugging the code correctly. To solve that I asked chrome to ignore the code in that library. That is a experimental feature in chrome for now. This article describes the way to achieve that: http://www.divshot.com/blog/tips-and-tricks/ignoring-library-code-while-debugging-in-chrome/

NSF
  • 2,499
  • 6
  • 31
  • 55
  • You can use Chrome's developer tools to do just that: https://developers.google.com/chrome-developer-tools/docs/javascript-debugging?csw=1#breakpoints-on-javascript-event-listeners – Felix Kling Feb 02 '14 at 01:13
  • I did a Google search for this question, and I found [several search results that may be useful in this situation](https://www.google.com/#q=step+through+code+browser+javascript). – Anderson Green Feb 02 '14 at 01:16
  • @isherwood It isn't clear whether this question is about Google Chrome, though. The question doesn't mention any particular web browser. – Anderson Green Feb 02 '14 at 01:36
  • 1
    Which makes that a perfect duplicate. As you said, no browser is specified. – isherwood Feb 02 '14 at 01:37

1 Answers1

2

What you are looking for are Event Listener Breakpoints. In Chrome Developer Tools you can find them on the Sources tab.

Link curtesy of @FelixKling.

Tibos
  • 27,507
  • 4
  • 50
  • 64
  • I'm not sure if this question is about Google Chrome, though: the question doesn't specify any browser. – Anderson Green Feb 02 '14 at 01:35
  • From http://getfirebug.com/doc/breakpoints/demo.html#event : Breakpoints on Event Handlers - This feature not yet implemented. Doing development mostly in Chrome i haven't had as much experience with other environments. Feel free to provide a better answer regarding those. – Tibos Feb 02 '14 at 01:40