[英]Chrome Developer Tools, using inspection functions inside script tags
I've looked around on google and I cannot figure out to use for instance the dir() function within the web page I'm working on, I would like to have it spit out debug statements, as I'm used to doing with Firebug. 我在google上环顾四周,我无法想象在我正在处理的网页中使用dir()函数,我想让它吐出调试语句,因为我习惯这样做萤火虫。
A clearer example 一个更清晰的例子
What I want is to do the following. 我想要的是做以下事情。
<script>
a=document.getElementById('gabber');
dir(a);
</script>
However doing this gets an undefined error. 但是这样做会得到一个未定义的错误。
console.dir works for me: console.dir适合我:
console.dir(document.getElementById('foo'));
You can see all the functions available on the console like this: 您可以在控制台上看到所有可用的功能,如下所示:
for (var n in console) {
if (typeof console[n] == "function") {
console.log(n);
}
}
(I get the following on Chrome 5.0.322.2:) (我在Chrome 5.0.322.2上获得以下内容:)
debug
error
info
log
warn
dir
dirxml
trace
assert
count
markTimeline
time
timeEnd
group
groupEnd
The console can be found at: 控制台可在以下位置找到:
Side note: console.log()
functions will also appear here. 旁注: console.log()
函数也会出现在这里。
Did you try to use console.log(var)
? 你尝试使用console.log(var)
吗? It dumps object into javascript console ( Ctrl + Shift + j ) and you can explore the structure in comfortable way. 它将对象转储到javascript控制台( Ctrl + Shift + j ),您可以以舒适的方式探索结构。
Chrome console output http://img411.imageshack.us/img411/1739/chromeconsolelog.png Chrome控制台输出http://img411.imageshack.us/img411/1739/chromeconsolelog.png
"jQuerify" --- Perfect extension to embed jQuery into Chrome Console as simple as you can imagine. “jQuerify”---将jQuery嵌入Chrome控制台的完美扩展,就像您想象的那样简单。 This extension also indocates if jQuery has been already embeded into page. 如果jQuery已经嵌入页面,这个扩展也会提出异议。
This extension used to embed jQuery into any page you want. 此扩展用于将jQuery嵌入到您想要的任何页面中。 It allows to use jQuery in the console shell (You can invoke Chrome console by "Ctrl+Shift+j"). 它允许在控制台shell中使用jQuery(您可以通过“Ctrl + Shift + j”调用Chrome控制台)。
To embed jQuery into selected tab click on extention button. 要将jQuery嵌入到选定的选项卡中,请单击“扩展”按钮。
LINK to extension: https://chrome.google.com/extensions/detail/gbmifchmngifmadobkcpijhhldeeelkc 链接到扩展程序: https : //chrome.google.com/extensions/detail/gbmifchmngifmadobkcpijhhldeeelkc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.