bookmarks.removeTree()
bookmarks.removeTree()
は、ブックマークフォルダーやその要素を再帰的に削除するメソッドです。
ブックマークが見つからなかった場合は runtime.lastError
がセットされ、エラーの有無はコールバック内で確認できます。
構文
js
browser.bookmarks.removeTree(
id, // 文字列
callback, // 関数(省略可)
);
引数
id
-
子要素とともに削除されるフォルダーノードの ID を表す
string
です。 callback
省略可-
ノードが削除された際に実行される関数です。この関数に渡される引数はありません。
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
removeTree |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
使用例
以下の例は、"MDN" という名前のフォルダーを探し、それ自身とその子要素をすべて削除するものです。
js
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);
メモ:
この API は Chromium の chrome.bookmarks
API に基づいています。また、このドキュメントは bookmarks.json
における Chromium のコードから作成されています。Microsoft Edge の実装状況は Microsoft Corporation から提供されたものであり、ここでは Creative Commons Attribution 3.0 United States License に従います。