How to Open a Web Link in a New Browser Window from a PDF
Question details
The user wants to configure a PDF document to open hyperlinks in a new, separate browser window rather than navigating away from the active PDF view.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Adding interactive hyperlinks to a PDF document that require keeping the original document open while viewing external web content.
- Observed behavior
- By default, clicking a link in a PDF might replace the current PDF window with the linked web page, disrupting the reading experience.
Ensure you have permission to edit the PDF document and access to a PDF editor that supports JavaScript functionality. Be aware that some strict PDF security settings may block JavaScript execution by default.
Use JavaScript to Force Links to Open in a New Window
Apply a simple JavaScript command to your PDF hyperlink to instruct the PDF reader to launch the URL in a separate browser window.
Standard PDF hyperlinks sometimes replace the active document view with the target web page. By using a custom JavaScript action instead of a standard URL link, you can ensure the link always launches in a fresh browser tab or window.
Open your PDF document in a capable PDF editor such as Adobe Acrobat. Navigate to the 'Tools' menu, select 'Edit PDF', and click on 'Link' followed by 'Add/Edit Web or Document Link'.
Draw a rectangle over the text or image where you want the clickable link to be. In the 'Create Link' dialog box that appears, select 'Custom link' under the Link Action section and click 'Next'.
Go to the 'Actions' tab in the Link Properties window. From the 'Select Action' dropdown menu, choose 'Run a JavaScript' and then click the 'Add' button.
In the JavaScript Editor window, enter the following code: app.launchURL("http://www.yourwebsite.com", true); Replace the example URL with your desired web address. The 'true' parameter is what forces the new window.
Click 'OK' to close the JavaScript Editor, then click 'OK' again to close the Link Properties window. Save your PDF document to apply the changes.

Use WPS PDF to Add and Manage Hyperlinks
WPS Office provides a comprehensive PDF editor that allows you to easily insert, edit, and manage hyperlinks in your PDF documents without needing complex scripts.
- 1. Open your PDF: Launch WPS Office and open the PDF document you wish to edit.
- 2. Access the Link tool: Go to the 'Edit' tab on the top toolbar and select the 'Link' option.
- 3. Draw the link area: Choose 'Add/Edit Link' and draw a box over the text or image you want to make clickable.
- 4. Set the target URL: In the pop-up window, select 'Open a web page' and enter your target URL.
- 5. Save the document: Click 'OK' and save your document. The link will now direct users to the specified web address when clicked.

Frequently Asked Questions
Why does my PDF link replace the current document instead of opening a new tab?
By default, some PDF readers handle standard hyperlinks by navigating within the same window. Using a JavaScript command like app.launchURL(url, true) forces the reader to pass the URL to the default web browser to open in a new window.
Will this JavaScript link work on mobile PDF readers?
JavaScript support varies significantly across mobile PDF readers. While it works reliably on desktop versions of Adobe Acrobat and Reader, many mobile apps disable or do not support PDF JavaScript for security reasons, meaning the link might be unresponsive on smartphones.
Can I link to a local file instead of a web URL using this method?
The app.launchURL method is primarily designed for web URLs (HTTP/HTTPS). To link to a local file, it is better to use the standard 'Open a file' link action in your PDF editor rather than using JavaScript.
How do I enable JavaScript in my PDF reader if the link isn't working?
In Adobe Acrobat or Reader, go to Edit > Preferences > JavaScript, and ensure that 'Enable Acrobat JavaScript' is checked. If it is disabled, JavaScript-based links will not execute when clicked.




