This script adds additional JavaScript debugging methods.
- debugProps(obj, name, maxdepth, maxprops)
Display the properties of an object. Typically 'name' is a quoted version of 'obj': see example.
Parameters
obj
- the object whose properties are displayed
parent
- a name for the object
maxdepth
- if a property has children, and the recursion depth is less than this number, the children are also displayed.
maxprops
- JavaScript objects tend to have a few hundred properties. This parameterr limits the output no more than the given number of properties.
Example input: a <style> section declared thus:
<style id="style" type="text/css">
button {
font-weight:bold;
text-align:center;
}
</style>
Example command:
debugProps(document.getElementById("style"), "sx", 3, 5)
Example output:
3:55.997 <tstM.php> s.disabled: false
3:55.998 <tstM.php> s.media:
3:55.998 <tstM.php> s.type: text/css
3:55.999 <tstM.php> s.scoped: false
3:56.000 <tstM.php> s.sheet: [object CSSsSheet]
3:56.000 <tstM.php> - s.sheet.insertRule: function insertRule()[native]
3:56.001 <tstM.php> - s.sheet.deleteRule: function deleteRule()[native]
3:56.002 <tstM.php> - s.sheet.ownerRule: null
3:56.003 <tstM.php> - s.sheet.cssRules: [object CSSRuleList]
3:56.003 <tstM.php> - - s.sheet.cssRules.0: [object CSSsRule]
3:56.004 <tstM.php> - - s.sheet.cssRules.item: function item()[native]
3:56.004 <tstM.php> - - s.sheet.cssRules.length: 1
3:56.005 <tstM.php> - s.sheet.type: text/css
3:56.005 <tstM.php> - s.sheet . . . (6 more properties))
3:56.006 <tstM.php> s . . . (201 more properties))
- debugTagTree(obj, name, maxdepth)
Display a tree of DOM elements.
Typically 'name' is a quoted version of 'obj': see example.
- obj
- the object to dump
- name
- name of obj; typically the same as passed to the first argument, but in quotes
- maxdepth
- depth to descend into children (the function recurses while reducing this value)
Example input: text that appears like this:
Test debuglog.php
Example command:
debugTagTree(document.getElementById("intro"), "intro", 3)
Example output:
75:16.098 <testdebuglog.php> intro: element P
75:16.099 <testdebuglog.php> intro - - {id = intro}
75:16.099 <testdebuglog.php> - intro[0]: "Test "
75:16.100 <testdebuglog.php> - intro[1]: element A
75:16.100 <testdebuglog.php> - intro[1] - - {target=logwindow}
75:16.101 <testdebuglog.php> - intro[1] - - {href=/pictools/debuglog.php}
75:16.101 <testdebuglog.php> - - intro[1][0]: "debuglog.php"