How to Detect Whether a PDF Is Open on Mobile or Desktop | PDF Support
Question details
The user needs to detect the platform (mobile or desktop) when a PDF is opened, in order to apply different submission methods since custom JavaScript submit buttons fail on mobile devices.

- Product
- Device & OS
- not provided
- Scenario
- Creating an interactive cross-platform PDF form requiring a functional custom Submit button.
- Observed behavior
- The custom JavaScript Submit button works on desktop computers but fails to execute when the PDF is viewed on mobile devices.
Keep in mind that JavaScript support in PDF viewers varies significantly across different applications and mobile operating systems. Always test your interactive forms on the native mobile PDF viewers your audience is most likely to use.
Implement a Visible Warning Field for Unsupported Mobile Viewers
Since many mobile PDF viewers disable or restrict JavaScript entirely, platform detection scripts might not run at all. Creating a fallback UI ensures mobile users know how to proceed.
Relying solely on JavaScript to detect mobile environments is flawed if the mobile app itself blocks JavaScript execution. A better approach is an 'opt-out' logic: display a warning by default, and hide it only if JavaScript runs successfully.
Add a new text field in your PDF form containing a message like: 'Interactive submission is not supported on your current PDF viewer. Please use a desktop computer.'
Open the text field properties and ensure the visibility setting is configured to 'Visible' by default so it appears instantly upon opening the PDF.
Navigate to the document-level JavaScript settings and add a script to hide the field when executed: this.getField('YourWarningFieldName').display = display.hidden;
Open the form on a mobile device without JavaScript support. The script will fail to run, leaving the warning visible to guide the user. On a desktop, the script runs, and the warning vanishes.

Use the app.platform Property for OS Detection
If you are targeting mobile PDF viewers that do support basic Acrobat JavaScript, you can use the built-in app.platform property to identify the underlying operating system.
Manage and Fill PDF Forms Seamlessly with WPS Office
Avoid complex JavaScript compatibility issues by using WPS Office. Our built-in PDF reader offers robust cross-platform support for viewing, filling, and managing PDF forms on both desktop and mobile devices without losing data or functionality.
- 1. Download the software: Install WPS Office on your desktop or mobile device to access the integrated PDF editor.
- 2. Open your form: Launch WPS Office and open your interactive PDF form directly within the application.
- 3. Fill the form fields: Use the straightforward form filling tools to complete the document, bypassing complicated JavaScript errors.
- 4. Save and share: Save the filled PDF natively and share it via email or cloud storage directly from your device.

Frequently Asked Questions
Why doesn't my PDF JavaScript work on mobile devices?
Many mobile PDF viewer apps intentionally restrict or completely disable JavaScript execution for security and performance reasons. This prevents embedded scripts, like custom submit buttons, from functioning as they do on desktop computers.
What values does the app.platform script return?
In supported environments, the app.platform property typically returns a string representing the operating system, such as 'WIN' for Windows, 'MAC' for macOS, or specific identifiers for UNIX systems.
Is there a universal PDF form submit button that works on all mobile platforms?
There is no universal JavaScript solution for PDF forms across all mobile devices because different reader apps handle interactive elements uniquely. Instead of complex JavaScript, using standard HTML forms or basic 'mailto:' links is often much more reliable for mobile audiences.




