Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

breaking on jscript runtime error permission denied

282 views
Skip to first unread message

Julian

unread,
Jul 31, 2010, 11:53:56 AM7/31/10
to
I am trying to learn JavaScript working with Jeremy Keith's book "DOM
Scripting". I have written a function (below) as a way of
understanding better about nodes. This works fine on FireFox -
although it never finds attribute (type 2) nodes! On IE8 , when it
gets to "if (node.nodeType == 1)" it throws up the "Permission Denied"
error and the script stops. I'm beat. Can anyone help me, please.
Thanks. And why do type 2 nodes not show up?
------------------------------
var depth = 0;
function family(node,count) {
// indents
for (var i = 0; i < depth; i++)
document.write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");

// start writing about this element
document.write(depth + "/" + count + ": Element is type = " +
node.nodeType + ", name = " + node.nodeName + ", ");

// if it's tag show tagname else show value
if (node.nodeType == 1) {
document.write(" tag = &lt;");
document.write(node.tagName);
document.write("&gt;");
}
else {
document.write("value = '" + node.nodeValue + "'");
}

// if there are any children
if (node.hasChildNodes) {

// get the children
var cn = node.childNodes;

// tell us how many
document.write(". The element has " + cn.length + " child")
if (cn.length > 1) document.write("ren");
document.write(".<br />");

// process the children
depth++;
for (var c = 0; c < cn.length; c++) {
family(cn[c],c);
}
depth--;
}
else {
document.write(".<br />");
}
}
--------------------------

0 new messages