Class Bookmark

書籤

代表書籤的物件。

// Insert a bookmark at the cursor position and log its ID.
var doc = DocumentApp.getActiveDocument();
var cursor = doc.getCursor();
var bookmark = doc.addBookmark(cursor);
Logger.log(bookmark.getId());

方法

方法傳回類型簡短說明
getId()String取得 Bookmark 的 ID。
getPosition()Position取得 DocumentBookmarkPosition
remove()void刪除 Bookmark

內容詳盡的說明文件

getId()

取得 Bookmark 的 ID。文件內的 ID 不會重複。

回攻員

StringBookmark 的 ID,在文件中不得重複

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getPosition()

取得 DocumentBookmarkPosition。只要 Bookmark 沒有刪除,即使文件結構改變了文件結構,Position 仍會保持準確性。

回攻員

PositionBookmark 的位置

授權

使用這個方法的指令碼必須取得以下一或多個範圍的授權:

  • 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