简体   繁体   English

尝试使用Firebug在JavaScript文件中定位函数

[英]Trying to locate function in JavaScript files using Firebug

I'm trying to locate this function call myFooBar() that is referenced inline in some HTML but the page loads tons of JavaScripts and it's quite some work to search that function in each of those files. 我正在尝试找到这个函数调用myFooBar(),它在某些HTML中被内联引用,但页面加载了大量的JavaScripts,并且在每个文件中搜索该函数是相当有用的。 How can I locate in which JavaScript file this function lives using Firebug? 如何使用Firebug找到此函数所在的JavaScript文件?

  • Open the Script tab. 打开“脚本”选项卡。
  • Type your function name in search box at top right of firebug (see spyglass). 在firebug右上角的搜索框中键入您的函数名称(请参阅spyglass)。
  • You can use the next and previous buttons to jump between occurrences of the function. 您可以使用下一个和上一个按钮在函数的出现之间跳转。
  • The file name appears in the Script tab's bar, and changes for each occurrence. 文件名出现在“脚本”选项卡的栏中,并且每次出现都会更改。

By going to the script tab you are only searching js on the page, if you try this in the html or css tabs you will only be searching for occurrences of your entered text within those specific content types. 通过转到脚本选项卡,您只搜索页面上的js,如果您在html或css选项卡中尝试此操作,则只会在这些特定内容类型中搜索输入文本的出现次数。

If you want only to see the source code of the method and know the correct function name. 如果只想查看方法的源代码并知道正确的函数名称。 Just execute alert( myFooBar ); 只需执行alert(myFooBar); on Firebug console. 在Firebug控制台上。

If you like to see the function definition type the function name in the console. 如果您想查看函数定义,请在控制台中键入函数名称。 If you want to know which java script file then Right click the inspect element.Select the resource tab.Then put the function name on the search box to search for it.You will see the number of occurrences of that function.Hope this tip will help as well. 如果你想知道哪个java脚本文件然后右键单击inspect元素。选择资源选项卡。然后将函数名称放在搜索框中以搜索它。你将看到该函数的出现次数。希望这个提示将也有帮助。

But also remember that it is not possible always to find out which java file it was.If you are using smarty in your project then some java script might be inline inside the tpl file 但是还要记住,不可能总是找出它是哪个java文件。如果你在项目中使用smarty,那么一些java脚本可能内嵌在tpl文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM