> For the complete documentation index, see [llms.txt](https://docs.horizon.ipaper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.horizon.ipaper.io/horizon-api/methods-and-events/page.md).

# Page

### `getPage`

Get a specific page by providing a page `guid`. Returns an `ILeafletPage`.

```javascript
const page = api.page.getPage(pageGuid);
console.log('Page', Page);
```

`ILeafletPage`

<table><thead><tr><th width="307">Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>$type</td><td><code>'page'</code></td><td>content type</td></tr><tr><td>pageGuid</td><td><code>string</code></td><td>the unique page guid</td></tr><tr><td>pageNumber</td><td><code>number</code></td><td>the page number</td></tr></tbody></table>

### `getPages`

Get all pages in the experience. Returns an array of `ILeafletPage`.

```javascript
const pages = api.page.getPages();
console.log('Pages', pages);
```

`ILeafletPage`

<table><thead><tr><th width="307">Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>$type</td><td><code>'page'</code></td><td>content type</td></tr><tr><td>pageGuid</td><td><code>string</code></td><td>the unique page guid</td></tr><tr><td>pageNumber</td><td><code>number</code></td><td>the page number</td></tr></tbody></table>

### `goToPage`

Scroll to a specific page by providing a page `guid`.

```javascript
api.page.goToPage(pageGuid);
```

### `goToNextPage`

Scroll to next page.

```javascript
api.page.goToNextPage();
```

### `goToPreviousPage`

Scroll to previous page.

```javascript
api.page.goToPreviousPage();
```

### `getPageElement (deprecated)`

{% hint style="warning" %}
This command is deprecated and will be removed from the API in the near future
{% endhint %}

### `getPagesInView` <a href="#getchaptersinview" id="getchaptersinview"></a>

Get all pages currently in view. Returns an array of `ILeafletPage`.

```javascript
const inView = api.page.getPagesInView();
console.log('In view', inView);
```

`ILeafletPage`

<table><thead><tr><th width="307">Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>$type</td><td><code>'page'</code></td><td>content type</td></tr><tr><td>pageGuid</td><td><code>string</code></td><td>the unique page guid</td></tr><tr><td>pageNumber</td><td><code>number</code></td><td>the page number</td></tr></tbody></table>

## Subscription events <a href="#subscription-events" id="subscription-events"></a>

The following events can be subscribed to in order to execute code when they occur. The code that should be executed is passed as a callback function when subscribing. You can set up multiple subscriptions to the same event.

These can be very useful fx. for tracking with Google Analytics, etc.

### `subscribe` <a href="#subscribe" id="subscribe"></a>

Subscribe to pages entering the viewport.

```javascript
api.page.subscribe((pageEvent) => {
    // your code
});
```

`pageEvent`

<table><thead><tr><th width="307">Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>action</td><td><code>'viewEnter'</code> | <code>'viewLeave'</code></td><td>name of the event action that occurred</td></tr><tr><td>source</td><td><code>undefined</code></td><td>property not in use</td></tr><tr><td>value</td><td><code>ILeafletPage</code></td><td>the page the event occurred for</td></tr></tbody></table>

`ILeafletPage`

<table><thead><tr><th width="307">Property</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>$type</td><td><code>'page'</code></td><td>content type</td></tr><tr><td>pageGuid</td><td><code>string</code></td><td>the unique page guid</td></tr><tr><td>pageNumber</td><td><code>number</code></td><td>the page number</td></tr></tbody></table>

### `unsubscribe` <a href="#unsubscribe" id="unsubscribe"></a>

In addition, when you set up a subscription you will get an `unsubscribe` function returned which can be used to cancel the subscription at any time. For example:

```javascript
let mySubscription = api.page.subscribe((pageEvent) => {
    // your code
});

mySubscription.unsubscribe();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.horizon.ipaper.io/horizon-api/methods-and-events/page.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
