Class Bookmark

Bookmark

An object representing a 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());
 

Methods

MethodReturn typeBrief description
getId()StringGets the ID of the Bookmark.
getPosition()PositionGets the Position of the Bookmark within the Document.
remove()voidDeletes the Bookmark.

Detailed documentation

getId()

Gets the ID of the Bookmark. The ID is unique within the document.

Return

String — the Bookmark's ID, which is unique within the document


getPosition()

Gets the Position of the Bookmark within the Document. The Position remains accurate so long as the Bookmark is not deleted, even if the script changes the document structure.

Return

Position — the position of the Bookmark


remove()

Deletes the Bookmark. Calling this method on a Bookmark that has already been deleted has no effect.

发送以下问题的反馈:

此网页
Apps Script
Apps Script