代表書籤的物件。
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); // Insert a bookmark at the cursor position (in the active tab) and log its ID. const cursor = doc.getCursor(); const bookmark = documentTab.addBookmark(cursor); Logger.log(bookmark.getId());
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
get | String | 取得 Bookmark 的 ID。 |
get | Position | 取得 Document 內 Bookmark 的 Position。 |
remove() | void | 刪除 Bookmark。 |
內容詳盡的說明文件
get Id()
取得 Bookmark 的 ID。這個 ID 在 Document 中是唯一的。
回攻員
String:Bookmark 的 ID,在 Document 中為唯一值。
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Position()
取得 Document 內 Bookmark 的 Position。只要 Bookmark 未遭到刪除,Position 就會保持準確,即使指令碼變更文件結構也一樣。
回攻員
Position:Bookmark 的位置。
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove()
刪除 Bookmark。在已刪除的 Bookmark 上呼叫此方法不會產生任何效果。
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents