代表書籤的物件。
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 的 Bookmark。Position |
remove() | void | 刪除 Bookmark。 |
內容詳盡的說明文件
getId()
取得 Bookmark 的 ID。ID 在 DocumentTab 中不得重複。
回攻員
String:Bookmark 的 ID,在 DocumentTab 內不得重複。
授權
使用這個方法的指令碼需要下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPosition()
取得 DocumentTab 內 Bookmark 的 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