Document JavaScript

By Cynthia, 7 December, 2025

Document JavaScripts are variable and function definitions that are generally useful to a given document, but are not applicable outside the document.

  • Variable definitions: Define variables at the document level to make them visible to any executing script.
  • Function definitions: Define functions at the document level that support the user interaction with the document. These functions may be utility functions for handling common tasks for string or number manipulation, or functions that execute lengthy scripts called by actions initiated by a user interacting with form fields, bookmarks, page changes, etc.

To create or access document level scripts in Foxit PDF Editor, select Form > JavaScript > Document JavaScript. The pop-up JavaScript Functions dialog box (or an external JavaScript editor if you have specified one in File > Preferences > JavaScript) enables you to add, edit, or delete document level scripts. All the document level scripts are stored within the PDF document.

In JavaScript Functions dialog box, you will see the following buttons:

  • Close – Closes the dialog box.
  • Add – After typing a new Script Name, a JavaScript Editor dialog box pops up. You can create and edit document level scripts here. To change the font of JavaScripts, click the Font button.
  • Edit – The JavaScript Editor dialog box pops up, enabling you to modify the JavaScripts you create.
  • Delete – Delete the JavaScript you selected.
HTML User Manual Product
Foxit PDF Editor for Windows