views:

351

answers:

4

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.

A: 

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.

Nick Craver
Ok, what I want is to do the following. <script> a=document.getElementById('gabber'); dir(a); </script>However doing this gets an undefined error. apparently markdown doesn't work in these little comments?
flaxeater
@flaxeater - Same place, except use `console.dir(document);` for example.
Nick Craver
A: 

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

Ivan Nevostruev
+4  A: 

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
Annie
yes thanks, that's what I was missing. thanks a bunch. Sorry apparently I cannot upvote you either. :(
flaxeater
A: 

"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

Andrey