EdwardKing
12-17-2007, 09:24 AM
I have a object,and it contains some method,like follows:
node object has getSelected(),hasChildren() and getChildren() method,then I want to show its all child,I use recursion:
function showAllNode(node){
if(node.getSelected().hasChildren()){
var obj1=node1.getSelected().getChildren();
for(i=0;i<obj1.length;i++){
showAllNode(obj1[i]);
}
}
else{
alert(node1.getText());
}
}
when I execute above code,I find the recursion can execute first time and second time well,but when it recursion the third time,it raise javascript error,it say "object don't support this method or method" at the line " if(node.getSelected().hasChildren())".
My question how to determine a object method is validate?
Thanks
node object has getSelected(),hasChildren() and getChildren() method,then I want to show its all child,I use recursion:
function showAllNode(node){
if(node.getSelected().hasChildren()){
var obj1=node1.getSelected().getChildren();
for(i=0;i<obj1.length;i++){
showAllNode(obj1[i]);
}
}
else{
alert(node1.getText());
}
}
when I execute above code,I find the recursion can execute first time and second time well,but when it recursion the third time,it raise javascript error,it say "object don't support this method or method" at the line " if(node.getSelected().hasChildren())".
My question how to determine a object method is validate?
Thanks