Other PDF Issues

How to Detect Whether a PDF Is Open on Mobile or Desktop | PDF Support

Huda QurayshiHuda Qurayshi Nov 5, 2026 870 views

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.

How to Detect Whether a PDF Is Open on Mobile or Desktop
Product
PDF
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.
Before you start

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.

Solution 1Recommended

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.

1
Create a warning text field

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.'

2
Set visibility to default

Open the text field properties and ensure the visibility setting is configured to 'Visible' by default so it appears instantly upon opening the PDF.

3
Add document-level JavaScript

Navigate to the document-level JavaScript settings and add a script to hide the field when executed: this.getField('YourWarningFieldName').display = display.hidden;

4
Test the fallback

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.

Implement a Visible Warning Field for Unsupported Mobile Viewers
Reliable Fallback: This logic guarantees that users on restricted viewers aren't left clicking a broken button, vastly improving the user experience on mobile platforms.
Cross-Platform PDF Management

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. 1. Download the software: Install WPS Office on your desktop or mobile device to access the integrated PDF editor.
  2. 2. Open your form: Launch WPS Office and open your interactive PDF form directly within the application.
  3. 3. Fill the form fields: Use the straightforward form filling tools to complete the document, bypassing complicated JavaScript errors.
  4. 4. Save and share: Save the filled PDF natively and share it via email or cloud storage directly from your device.
Seamless PDF form filling experience across Windows, Mac, iOS, and Android.Highly compatible with standard interactive PDF elements without complex coding.Includes a powerful suite of PDF editing, annotating, and conversion tools.Fully compatible with Microsoft Office document formats (Word, Excel, PowerPoint).
microsoft office alternative - wps office

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.