Bookmark

An object representing a bookmark.

```javascript
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());
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/document/bookmark#getId()` | `String` | Gets the ID of the `Bookmark`. |
| `https://developers.google.com/apps-script/reference/document/bookmark#getPosition()` | `https://developers.google.com/apps-script/reference/document/position` | Gets the `https://developers.google.com/apps-script/reference/document/position` of the `Bookmark` within the `https://developers.google.com/apps-script/reference/document/document-tab`. |
| `https://developers.google.com/apps-script/reference/document/bookmark#remove()` | `void` | Deletes the `Bookmark`. |

## Detailed documentation

### `getId()`

Gets the ID of the `Bookmark`. The ID is unique within the `https://developers.google.com/apps-script/reference/document/document-tab`.

#### Return


`String` --- The `Bookmark`'s ID, which is unique within the `DocumentTab`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getPosition()`

Gets the `https://developers.google.com/apps-script/reference/document/position` of the `Bookmark` within the `https://developers.google.com/apps-script/reference/document/document-tab`. The `Position` remains accurate so long as the `Bookmark` is not deleted, even if the script
changes the document structure.

#### Return


`https://developers.google.com/apps-script/reference/document/position` --- The position of the `Bookmark`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_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.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`