Stay organized with collections Save and categorize content based on your preferences.
BookmarkAn object representing a bookmark.
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());Detailed documentation
getId()
Gets the ID of the Bookmark
. The ID is unique within the DocumentTab
.
String
— The Bookmark
's ID, which is unique within the DocumentTab
.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getPosition()
Gets the Position
of the Bookmark
within the DocumentTab
. The Position
remains accurate so long as the Bookmark
is not deleted, even if the script changes the document structure.
Position
— The position of the Bookmark
.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
remove()
Deletes the Bookmark
. Calling this method on a Bookmark
that has already been deleted has no effect.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["A Bookmark object represents a specific location within a Google Doc, allowing you to programmatically interact with it."],["You can create a Bookmark using the `addBookmark()` method of a DocumentTab, inserting it at the current cursor position."],["Bookmarks offer methods to retrieve their unique ID (`getId()`), get their position within the document (`getPosition()`), and remove them (`remove()`)."],["Bookmark positions remain valid even after document modifications, unless the bookmark itself is deleted."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4