How to find object with property having specified value?
This code doesn't work
function findPropertyByValue(needle, fObj)
{
var i;
for(i in fObj){
if(fObj==needle) return i;
}
var success;
if(fObj.firstChild!=null){
success=findPropertyByValue(needle, fObj.firstChild);
if(success!=null) return "->"+success;
}
while(fObj.nextSibling!=null){
success=findPropertyByValue(needle, fObj=fObj.nextSibling);
if(success!=null) return "->"+success;
}
return null;
}
function CTRL21_7::OnClick(eventObj)
{
var dest=findPropertyByValue("something", XDocument.DOM);
if(dest!=null) XDocument.UI.Alert(dest);
}
There is error on row "for(i in fObj){" (object doesn't support command)
What's wrong? How to do it?