我尝试在活动页面中执行此操作。
// When the browser action is clicked, call the
// getBm function.
chrome.browserAction.onClicked.addListener(getBm);
function getBm () {
var url = 'test.html';
dumpBookmarks();
chrome.tabs.create({ url: url });
}
function dumpBookmarks() {
var b = chrome.bookmarks.getTree(
function(bookmarkTreeNodes) {
console.log(bookmarkTreeNodes); --------(1)
});
}
function dumpTreeNodes(bookmarkNodes) {
//do something here
}
这很好但是如果我尝试
console.log(dumpTreeNodes(bookmarkTreeNodes));
在(1)它抛出错误,
Error in response to bookmarks.getTree: TypeError: undefined is not a function