I've taken over a project which involves a lot of javascript (AJAX and whatnot). In tracking down functions, is there a way to find out which included .js
file contains a specific function?
I'm hunting through Firebug but can't find where it isolates the specific file which contains the javascript function. What am I missing?
I've taken over a project which involves a lot of javascript (AJAX and whatnot). In tracking down functions, is there a way to find out which included .js
file contains a specific function?
I'm hunting through Firebug but can't find where it isolates the specific file which contains the javascript function. What am I missing?
Share Improve this question asked Sep 26, 2011 at 18:27 user965641user965641 1371 gold badge2 silver badges11 bronze badges 2-
Place a breakpoint in front of your function and call it like so:
debugger;functionName()
. Then step into the function using the debugger and Firebug will list the source code of the function along with the name of the source file. – Augustus Kling Commented Sep 26, 2011 at 18:51 - And how would he place a breakpoint in front of a function he cannot find? The only way I know is to open the file containing the javascript and add the breakpoint at the right line number. Are you thinking of something else? – oligofren Commented Feb 18, 2013 at 11:55
3 Answers
Reset to default 5The Web Developer plugin (for FF and Chrome http://chrispederick./work/web-developer/) has a "View JavaScript" feature that shows all of the JS that a page is referencing on a single page. CTRL-F from there to find the function.
Fiddler will let you search through all requests, so you could load the page in Fiddler, then search for your function.
http://www.fiddler2./fiddler2/
Certain text editors, including Notepad++, allow you to search all files in a directory. You can use that to search for "function foo(" and that should pull it up.
Of course, that assumes the function is declared like that. It could also be assigned, which would be a bit more difficult. You'd have to search for something like "foo\s*=" (using Regex search).
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744307081a4567767.html
评论列表(0条)