flaxeater
flaxeater

Reputation: 690

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.

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.

Upvotes: 3

Views: 3934

Answers (4)

Andrey
Andrey

Reputation: 65

"jQuerify" --- Perfect extension to embed jQuery into Chrome Console as simple as you can imagine. This extension also indocates if jQuery has been already embeded into page.

This extension used to embed jQuery into any page you want. It allows to use jQuery in the console shell (You can invoke Chrome console by "Ctrl+Shift+j").

To embed jQuery into selected tab click on extention button.

LINK to extension: https://chrome.google.com/extensions/detail/gbmifchmngifmadobkcpijhhldeeelkc

Upvotes: 0

Ivan Nevostruev
Ivan Nevostruev

Reputation: 28713

Did you try to use console.log(var)? It dumps object into javascript console (Ctrl+Shift+j) and you can explore the structure in comfortable way.

Chrome console output http://img411.imageshack.us/img411/1739/chromeconsolelog.png

Upvotes: 0

Annie
Annie

Reputation: 6631

console.dir works for me:

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:)

debug
error
info
log
warn
dir
dirxml
trace
assert
count
markTimeline
time
timeEnd
group
groupEnd

Upvotes: 14

Nick Craver
Nick Craver

Reputation: 630349

The console can be found at:

  • Instpect Element
  • Click Scripts up top
  • Very bottom left, click the Show Console button

Side note: console.log() functions will also appear here.

Upvotes: 0

Related Questions