I can check if a folder is empty.
this.emptyfolder =开发者_JS百科 function(folderid) {
result = PlacesUtils.getFolderContents(folderid);
resultContainerNode = result.root;
if (resultContainerNode.ChildCount == 0) {
return true;
} else {
return false;
}
}
How to check if a folder exists even if it's empty?
- link to the PlacesUtils description
- link to the PlacesUtils code
many bookmarks service methods will throw if and item id does not exist, so for example PlacesUtils.bookmarks.getItemType(itemId); will throw. But actually, I'm missing your use-case, when working with folders you usually work with views, and you the don't bother about the fact a certain item id exists.
精彩评论