How to Add JavaScript to a PDF Page Open Event
Question details
The user wants to execute custom JavaScript code automatically when a specific page in a PDF document is opened.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Adding interactive or automated scripts to trigger upon viewing a specific page in a PDF document.
- Observed behavior
- The user needs to locate the Page Open trigger, which is found in the individual page properties rather than the general document-level JavaScript settings.
Ensure you have your JavaScript code written and tested in a code editor to prevent syntax errors before inserting it into your PDF document.
Configure Page Properties in Adobe Acrobat
Add a JavaScript action directly to the Page Open trigger using the Page Thumbnails pane.
Unlike document-level scripts that run when the entire PDF is opened, page-specific scripts must be bound to the page's individual properties. This ensures the script only triggers when the reader navigates to that exact page.
Launch your PDF in Adobe Acrobat and expand the Page Thumbnails pane on the left side of the window.
Right-click the specific page thumbnail where you want the script to run and select 'Page Properties' from the context menu.
Navigate to the 'Actions' tab. Under the 'Select Trigger' dropdown menu, choose the 'Page Open' option.
Under 'Select Action', choose 'Run a JavaScript'. Click the 'Add' button and paste your custom JavaScript code into the editor window.
Click 'OK' to save the properties, then save your PDF document. Reopen the document and navigate to the page to test the event.

Edit and Manage PDFs Easily with WPS Office
While advanced JavaScript scripting relies on specialized Adobe tools, WPS Office provides a free, lightweight, and highly compatible alternative for all your everyday PDF editing, conversion, and Office document needs.
- 1. Download and Install: Get WPS Office directly from the official website and run the quick installer.
- 2. Open Your PDF: Launch WPS PDF and drag your document into the workspace to start reading or editing.
- 3. Explore PDF Tools: Use the intuitive top ribbon to annotate, convert, sign, or merge your PDF files effortlessly.

Frequently Asked Questions
Why is my PDF JavaScript not running when the page opens?
Ensure that JavaScript execution is enabled in your PDF viewer's security preferences. In Adobe Acrobat, go to Preferences > JavaScript and verify that 'Enable Acrobat JavaScript' is checked.
Can I add a JavaScript event to the entire PDF document instead of a single page?
Yes, document-level scripts execute when the PDF file itself is initially opened. You can add these by navigating to Tools > JavaScript > Document JavaScripts rather than using the individual page properties.
Does the Page Open action trigger every time I scroll back to the page?
Yes, typically the Page Open event triggers every time the specified page becomes the active, visible page in the document viewer, not just the first time it is viewed during a session.




