javascript Chrome 开发工具中的 Firebug DOM 选项卡相当于什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9732134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the equivalent to Firebug DOM tab in Chrome Dev tools?
提问by dbrin
I am used to using DOM tab to inspect global JS variables that are present on the page in Firebug. What is the equivalent of it in Chrome Developer tools?
我习惯于使用 DOM 选项卡来检查 Firebug 页面上存在的全局 JS 变量。它在 Chrome 开发者工具中的等价物是什么?
采纳答案by u283863
Type in window
, then you will see the window
object with everything inside it.
输入window
,然后您将看到其中window
包含所有内容的对象。
p.s: window
is the "top-most" object in a normal webpage. (Global scope) Since "Chrome Developer Tools" is specifically mentioned, we can safely assume that window
will always be the global scope.
ps:window
是普通网页中“最顶层”的对象。(全局范围)由于特别提到了“Chrome 开发者工具”,我们可以放心地假设它window
始终是全局范围。
Press Console
, then enter window
. Press enter
and now you can see a list of global variables, such as $
(jQuery) and document
.
按Console
,然后输入window
。按enter
,现在您可以看到一个全局变量列表,例如$
(jQuery) 和document
.
回答by Alex Ivasyuv
Yes, it's called "Properties".
是的,它被称为“属性”。
回答by Ronald
Execute the following in the Chrome console:
在 Chrome 控制台中执行以下操作:
for(variable in window) {
if(window.hasOwnProperty(variable)) {
console.log(variable);
}
}
for(variable in window) {
if(window.hasOwnProperty(variable)) {
console.log(variable);
}
}
回答by jeremysawesome
You might be looking for the Scripts
tab in Chrome dev tools.
您可能正在Scripts
Chrome 开发工具中寻找该选项卡。
Also, if you click on the Console
tab you can actually type in window.
. You will see a large list of items that are all accessible from the "window" (generally global) scope.
此外,如果您单击Console
选项卡,您实际上可以输入window.
. 您将看到一个很大的项目列表,这些项目都可以从“窗口”(通常是全局)范围内访问。
After you find the object or variable you are looking for in the list, you can press Enter
and Chrome will output the relevant information for your entry.
在列表中找到您要查找的对象或变量后,您可以按Enter
,Chrome 会输出您输入的相关信息。
回答by Mohsen
By setting a breakpoint in first line of your script in Scripttab you will see all the global variables in Scope Variablessection in right sidebar. Chrome dev tool will not show variables without a breakpoint but you still can access those from console.
通过在脚本选项卡中脚本的第一行设置断点,您将在右侧边栏中的范围变量部分中看到所有全局变量。Chrome 开发工具不会在没有断点的情况下显示变量,但您仍然可以从控制台访问这些变量。