简体   繁体   English

Chrome开发者工具,使用脚本标记内的检查功能

[英]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: 控制台可在以下位置找到:

  • Instpect Element Instpect元素
  • Click Scripts up top 单击顶部的脚本
  • Very bottom left, click the Show Console button 在左下角,单击“ 显示控制台”按钮

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.

相关问题 禁用chrome开发人员工具中的脚本编辑 - Disable script editing in chrome developer tools 如何在Chrome开发者工具中的JavaScript调试的部分视图中调试脚本? - How to debug a script inside partial view that load by javascript in Chrome Developer Tools? "使用 Chrome 开发者工具编辑 Javascript" - Editing Javascript using Chrome Developer Tools 无法使用 Chrome 开发者工具 + 应用程序脚本查明错误来源(Javascript 错误) - Can't pinpoint error origin using Chrome Developer Tools + Apps Script (Javascript error) 如何将 go 到 Chrome 开发者工具中 java 脚本文件中的特定行? - How to go to a specific line in a java script file in Chrome Developer Tools? 如何在 Chrome 开发者工具中禁用加载特定脚本 - How to disable a specific script on load in Chrome Developer Tools 有没有办法在Chrome Developer工具中评估源地图中的变量? - Is there a way to evaluate variable in source map inside the Chrome Developer tools? 使用Chromes开发人员工具查看时,网站Div标签重叠吗? - Website Div Tags overlapping when viewed using Chromes Developer tools? 是否可以使用Chrome Developer工具重新加载单个Javascript文件? - Is it possible to reload a single Javascript file using Chrome Developer tools? 如何使用深色主题检测Google Chrome开发者工具? - How to detect Google Chrome Developer tools using dark theme?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM