Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

bookmarks.removeTree()

The bookmarks.removeTree() method recursively removes a bookmark folder and all of its contents.

If the bookmark item could not be found, runtime.lastError is set, and you can check for it in the callback.

Syntax

chrome.bookmarks.removeTree(
  id,                 // string
  function() {...}    // optional function
)

This API is also available as browser.bookmarks.removeTree() in a version that returns a promise.

Parameters

id
A string specifying the ID of the folder node to be deleted along with its descendants.
callback Optional
A function to call once the nodes have been removed. No parameters are passed to this function.

Browser compatibility

Chrome Edge Firefox Firefox for Android Opera
Basic support Yes No 47.0 No 33

Examples

This example locates a bookmark folder named "MDN" and deletes it along with all of its contents.

function onRemoved() {
  if (chrome.runtime.lastError) {
    console.log(chrome.runtime.lastError);
  } else {
    console.log("bookmark item removed!");
  }
}

function removeMDN(searchResults) {
  if (searchResults.length) {
    chrome.bookmarks.removeTree(searchResults[0].id, onRemoved);
  }
}

chrome.bookmarks.search({ title: "MDN" }, removeMDN);

Acknowledgements

This API is based on Chromium's chrome.bookmarks API. This documentation is derived from bookmarks.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Makyen, wbamberg, Sheppy
 Last updated by: Makyen,