---
title: "JavaScript PDF form actions | Nutrient"
canonical_url: "https://www.nutrient.io/guides/web/forms/pdf-actions-support/"
md_url: "https://www.nutrient.io/guides/web/forms/pdf-actions-support.md"
last_updated: "2026-05-25T12:14:42.988Z"
description: "Explore key PDF actions and JavaScript tips to improve your document management and annotation efficiency with our comprehensive guide."
---

# Master PDF actions with JavaScript integration

A PDF action is similar to a web hyperlink, but it’s much more flexible. Nutrient Web SDK implements common actions as defined in Adobe’s PDF Reference (page 417ff).

| Action     | Nutrient class         | Use case                                            |
| ---------- | ---------------------- | --------------------------------------------------- |
| GoTo       | [`GoToAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.GoToAction.html)       | Go to a destination (page) in the current document. |
| URI        | [`URIAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.URIAction.html)        | Resolve a Uniform Resource Identifier (web link).   |
| SubmitForm | [`SubmitFormAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.SubmitFormAction.html) | Send data to a Uniform Resource Locator.            |
| ResetForm  | [`ResetFormAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.ResetFormAction.html)  | Set fields to their default values.                 |
| JavaScript | [`JavaScriptAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.JavaScriptAction.html) | Execute a script.                                   |
| Named      | [`NamedAction`](https://www.nutrient.io/api/web/NutrientViewer.Actions.NamedAction.html)      | Execute a predefined action.                        |

## GoToAction

A GoTo action can define a different `pageIndex` in the same document. Clicking it updates the scroll position to make the page visible, but it doesn’t update the zoom level.

## URIAction

A URI action contains a URI. When executing this annotation, Nutrient uses `window.open` to create a new browser tab, which also clears the opener as a security measurement to avoid allowing the target page to have access to your PDF state:

### ES6+

```js

let newWindow = window.open(action.uri, "_blank");
newWindow.opener = null;

```

### JAVASCRIPT

```js

var newWindow = window.open(action.uri, "_blank");
newWindow.opener = null;

```

## JavaScriptAction

Working with PDF JavaScript is available when using [Web SDK](/guides/web.md) in the browser. For more information, refer to the [operational mode](/guides/web/about/operational-modes.md) guide.

This is a PDF action for running arbitrary JavaScript. Actions are executed on a click. `WidgetAnnotation` and form fields can also define an `additionalActions` field, which is a dictionary of event name and action pairs. For more information about the additional actions of [`WidgetAnnotation`](https://www.nutrient.io/api/web/NutrientViewer.Annotations.WidgetAnnotation.html#additionalActions)s and [`FormField`](https://www.nutrient.io/api/web/NutrientViewer.FormFields.FormField.html#additionalActions)s, refer to the API documentation.

You can learn more about the security problems when using `_blank` in [this article from JitBit](https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/).

Refer to an individual browser’s documentation for a list of supported URI protocols. The most used protocols (`http`, `https`, and `mailto`) are supported in all [major browsers](https://www.nutrient.io/guides/web/pspdfkit-for-web/browser-support.md).

Here’s an example showing how to run JavaScript code when a `WidgetAnnotation` is focused. This is done using the `additionalActions` field:

```js

const widget = new NutrientViewer.Annotations.WidgetAnnotation({
  id: NutrientViewer.generateInstantId(),
  pageIndex: 0,
  formFieldName: "MyFormField",
  boundingBox: new NutrientViewer.Geometry.Rect({
    left: 100,
    top: 75,
    width: 200,
    height: 80
  }),
  additionalActions: {
    onFocus: new NutrientViewer.Actions.JavaScriptAction({
      script: "alert('onFocus')"
    })
  }
});

const formField = new NutrientViewer.FormFields.TextFormField({
  name: "MyFormField",
  annotationIds: NutrientViewer.Immutable.List([widget.id]),
  value: "Text shown in the form field"
});

instance.create([widget, formField]);

```

## NamedAction

A named action executes a predefined action. The following standard named actions are supported:

- `prevPage` — Go to the previous page.

- `nextPage` — Go to the next page.

- `firstPage` — Go to the first page.

- `lastPage` — Go to the last page.

A number of non-standard named actions are also supported:

- `fullScreen` — Enter fullscreen mode.

- `zoomIn` — Zoom in the document.

- `zoomOut` — Zoom out the document.

- `saveAs` — Download the document (if backend permissions allow it).

- `search` — Show the SDK search user interface (UI).

- `outline` — Show the SDK outline sidebar.

- `print` — Print the document (if permissions allow it).

Here’s an example of creating a link annotation with a `NamedAction` that navigates to the next page when the link is clicked:

```js

const linkAnnotation = new NutrientViewer.Annotations.LinkAnnotation({
  id: NutrientViewer.generateInstantId(),
  pageIndex: 0,
  boundingBox: new NutrientViewer.Geometry.Rect({
    left: 100,
    top: 100,
    width: 200,
    height: 50
  }),
  action: new NutrientViewer.Actions.NamedAction({
    action: "nextPage"
  })
});

```
---

## Related pages

- [Extract data from PDF form fields using JavaScript](/guides/web/forms/extract-form-data.md)
- [JavaScript PDF fillable form library](/guides/web/forms.md)
- [Read PDF form fields using JavaScript](/guides/web/forms/read-form-fields.md)
- [Flatten dynamic PDF forms using JavaScript](/guides/web/forms/flatten.md)
- [Validate PDF forms using JavaScript](/guides/web/forms/javascript-validation.md)

