Best JavaScript DOM Inspector (Browser)

D

Daniel Kirsch

RobG said:
Just curious - what benefit does a JavaScript-based DOM inspector have
over one that is available for free as a browser extension?

.... which might also be JavaScript based :)
 
A

Alex Vassiliev

All regular benefits of web application:
(1) easy to deploy with my application
(2) multiple browsers compatibility

Plus, if source code is available, I can invoke it from my js
application when it is exactly in the state I wanted to inspect plus I
can pass the reference to the exact object I wanted to inspect.
 
R

RobG

Alex said:
All regular benefits of web application:
(1) easy to deploy with my application
(2) multiple browsers compatibility

Plus, if source code is available, I can invoke it from my js
application when it is exactly in the state I wanted to inspect plus I
can pass the reference to the exact object I wanted to inspect.
[...]

Here is a 'DOMwalk' script I wrote some time ago as a quick 'n dirty
tree dump. If you give domReport() an id it will walk down from there.
If no id is given, it starts from the html element. I've tested it in
most modern browsers and it seems to be fine.

Everything is listed in a table with a node reference, with a bit of
effort a better presentation is possible. Nodes could be listed as <li>
elements and each parent node could have an associated <ul> element with
an onclick that collapses the branch. Node attributes could be in a
<span> beneath each node and be shown/hidden when the node is clicked on.

I had intentions of doing at least some of the above, but it seemed
pointless given that a perfectly serviceable DOM inspector comes free
with Geko browsers (there are probably some for other browsers too but I
haven't bothered to look).

Let me know if you want the above functionality added.
 
R

RobG

RobG said:
Alex said:
All regular benefits of web application:
(1) easy to deploy with my application
(2) multiple browsers compatibility

Plus, if source code is available, I can invoke it from my js
application when it is exactly in the state I wanted to inspect plus I
can pass the reference to the exact object I wanted to inspect.
[...]

Here is a 'DOMwalk' script I wrote some time ago as a quick 'n dirty
tree dump. If you give domReport() an id it will walk down from there.
If no id is given, it starts from the html element. I've tested it in
most modern browsers and it seems to be fine.
[...]


And here's the script... :-x


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> DOMwalk </title>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
var rpt = [];
function domWalk(n,x) {
rpt.push('<tr><td>' + x
+ '</td><td>' + n.nodeName
+ '</td><td>' + n.nodeType
+ '</tr>');
for (var i=0; i<n.childNodes.length; i++) {
domWalk(n.childNodes,x+'.'+i);
}
}

function domReport(s){
rpt.length = 0;
rpt.push('<table><tr><th>Index</th>'
+ '<th>nodeName</th><th>nodeType</th></tr>');
if ( s && '' != s) {
domWalk(document.getElementById(s),'');
} else {
domWalk(document.getElementsByTagName('html')[0],'0');
}
rpt.push('</table>');
document.getElementById('xx').innerHTML = rpt.join('');
}
</script>
</head>
<body onload="domReport();">

<div>
<p>this stuff is just so that there is something
in the document to report on.</p>
<p>Here is <b>some</b> text</p>
<p>Here is <b>some</b> <i>text</i></p>
<p>Here is some text</p>
</div>

<div id="xx"></div>

</body>
</html>
 
A

Alex Vassiliev

I was thinking more about JS object members browser. Something you can
use to inrospect the available properties and methods of given class.
Plust the ability to jump (chenge the focus) on the references, etc.

There are DOM browsers like this one:
http://slayeroffice.com/?c=/content/tools/suite.html
or
javascript:s=document.body.appendChild(document.createElement('script'));s.id='fs';s.language='javascript';void(s.src='http://slayeroffice.com/tools/suite/suite.js');

which will let you browse the DOM, but not the pure JS object graph.

But thnank for your example anyway... I guess I can modify it like this
to achive my desired results:
function domWalk(n,x) {
var members = '';
for(var m in n) members += m+';';
rpt.push('<tr><td>' + x
+ '</td><td>' + n.nodeName
+ '</td><td>' + n.nodeType
+ '</td><td>' + members
+ '</tr>');
for (var i=0; i<n.childNodes.length; i++) {
domWalk(n.childNodes,x+'.'+i);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top