如何知道哪个文件在Chrome控制台中定义了一个js全局变量? [英] How to know in which file that defined a js global var in chrome console?

查看:2205
本文介绍了如何知道哪个文件在Chrome控制台中定义了一个js全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,变量 Native

如何找出哪个文件和行变量是使用谷歌浏览器控制台定义的? code>(来自MooTools)已在全球范围内定义。我想知道在哪个文件中使用谷歌浏览器控制台定义了这个变量。使用chrome:

解决方案


$ b


  1. 打开Web Inspector
  2. 显示控制台并检查您要搜索的变量是否存在(例如:Native < kbd> Enter )

  3. 点击资源面板

  4. 输入 Native = var本地 Native = 在右上方的搜索字段中

  5. 您已获得结果!

这里, Native = 搜索。结果会自动突出显示,并打开相应的文件。在我的示例中,您可以看到 Native 声明位于 mootools.core.js ,第12行。





编辑:2015年3月(感谢)



您现在需要使用右上角的三点按钮找到搜索所有文件选项。




How to find out which file and line a variable was defined in using google chrome console?

For example, the variable Native (from MooTools) has been defined in global scope. I want to know in which file that defined this variable using google chrome console.

解决方案

Using chrome :

  1. Open the Web Inspector
  2. Show the console and check if the var you're searching for exists (ex : Native Enter)
  3. Click on the Resources panel
  4. Enter Native=, var Native or Native = in the top right search field
  5. You've got your result !

Here, there's only one result for the Native= search. The result is automatically highlighted, and the corresponding file opened. In my example, you can see the Native declaration was in mootools.core.js, line 12.

EDIT: March 2015 (thanks to TML)

The top right search field doesn't exist anymore, in latest Chrome versions.
Instead of, click on Show drawer in the top right corner (or hit Esc), and select the Search tab that just appeared in the bottom of your screen:

EDIT: November 2015 (thanks tzvi)

You now need to use the three-dot button in the top right corner to find a Search all files option.

这篇关于如何知道哪个文件在Chrome控制台中定义了一个js全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆