JavaScript Navigator pdfViewerEnabled Property

Beginner
5 min read
Updated: Nov 2026
5 examples
Property

Definition

navigator.pdfViewerEnabled is a read-only Navigator property that returns a Boolean: true if the browser can show PDFs inline when you navigate to them, false if the PDF is downloaded instead (MDN).

Read the notes below before you rely on this property. Prefer feature detection when support is limited.

Syntax

Use navigator.pdfViewerEnabled. Start with this line.

JavaScript
navigator.pdfViewerEnabled
CallWhat it does
navigator.pdfViewerEnabledPrimary signature.

Built into the browser. Read navigator.pdfViewerEnabled on Navigator — no import required.

Library declarations
JavaScript
navigator.pdfViewerEnabled

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*The current value of navigator.pdfViewerEnabled.

JavaScript Examples

Example 1 — Read the Boolean

Print the current inline-PDF capability flag.

JavaScript
console.log(navigator.pdfViewerEnabled);
Try It Yourself

How It Works

  1. Read the property. Returns a Boolean, not a string.
  2. true = inline capable. Built-in viewer or PDF extension.
  3. false = download path. External app may open the file.
  4. Read-only. You cannot assign a new value.

Example 2 — MDN if (!enabled)

Use MDN’s recommended guard when inline viewing is missing.

JavaScript
if (!navigator.pdfViewerEnabled) {
  console.log("The browser does not support inline viewing of PDF files.");
} else {
  console.log("Inline PDF viewing is supported.");
}
Try It Yourself

How It Works

  1. Negate the flag. MDN checks the unsupported case first.
  2. Unsupported branch. Perfect place for a download tip.
  3. Supported branch. Normal PDF links can open inline.
  4. Keep it simple. No MIME array walking required.

Example 3 — Friendly Label

Turn the Boolean into short UI copy for banners or buttons.

JavaScript
const label = navigator.pdfViewerEnabled
  ? "Open PDF in browser"
  : "Download PDF";

console.log(label);
Try It Yourself

How It Works

  1. Map Boolean → copy. Ternary keeps the UI string in one place.
  2. Inline path. Encourage opening the PDF in-tab.
  3. Download path. Set expectations when inline is unavailable.
  4. Still optional. Users may override how a given PDF is handled.

Example 4 — vs mimeTypes

Compare the modern Boolean with the legacy PDF MIME check.

JavaScript
const modern = Boolean(navigator.pdfViewerEnabled);
const legacy =
  "mimeTypes" in navigator &&
  "application/pdf" in navigator.mimeTypes;

console.log("pdfViewerEnabled: " + modern);
console.log("application/pdf in mimeTypes: " + legacy);
console.log("Prefer pdfViewerEnabled for new PDF UI decisions");
Try It Yourself

How It Works

  1. Modern signal. Dedicated Boolean for inline PDF support.
  2. Legacy signal. Named MIME entry — hard-coded / empty on modern engines.
  3. Compare for learning. Helps when reading older codebases.
  4. Ship the Boolean. MDN: this property replaces those legacy inferences.

Example 5 — UX Helper

Return a small plan: mode, button label, and tip text.

JavaScript
function pdfPlan() {
  if (navigator.pdfViewerEnabled) {
    return {
      mode: "inline",
      button: "View PDF",
      tip: "Opens in the browser when possible"
    };
  }
  return {
    mode: "download",
    button: "Download PDF",
    tip: "This browser may download PDFs instead of showing them"
  };
}

console.log(JSON.stringify(pdfPlan(), null, 2));
Try It Yourself

How It Works

  1. One decision point. Branch on the Boolean once.
  2. Return UI fields. Mode, button, and tip stay together.
  3. Inline plan. Encourage viewing in-browser.
  4. Download plan. Honest tip when inline viewing is off.

Browser Support

navigator.pdfViewerEnabled is Baseline Widely available (MDN, since about March 2023). Use it as the modern inline-PDF capability check.

✓ Baseline · Widely available

Navigator.pdfViewerEnabled

Supported in modern Chrome, Firefox, Safari, Edge, and Opera. Prefer it over legacy mimeTypes PDF sniffing.

95% Modern browser support
Google Chrome pdfViewerEnabled · modern versions
Full support
Microsoft Edge pdfViewerEnabled · Chromium
Full support
Apple Safari pdfViewerEnabled · modern versions
Full support
Mozilla Firefox pdfViewerEnabled · modern versions
Full support
Opera pdfViewerEnabled · modern versions
Full support
Internet Explorer No pdfViewerEnabled
Unavailable
navigator.pdfViewerEnabled Excellent

Bottom line: Safe for modern PDF UX. Read the Boolean, adjust labels/tips, and stop inferring from mimeTypes in new code.

Frequently Asked Questions

A Boolean: true when the browser can display PDF files inline (built-in viewer or PDF viewer extension), false when navigating to a PDF downloads it instead (MDN).
No. MDN marks it Baseline Widely available (since about March 2023). It is not Deprecated, Experimental, or Non-standard.
MDN’s pattern: if (!navigator.pdfViewerEnabled) { /* browser does not support inline viewing of PDF files */ }.
For new code, prefer pdfViewerEnabled. MDN notes it replaces legacy ways of inferring inline PDF support (including mimeTypes-based checks).
It means the browser supports inline PDF display when navigating to a PDF. Headers, site behavior, or user settings can still change how a specific file is handled.
No. It is read-only. You read the Boolean; you do not assign to it.

Next: permissions

Learn how navigator.permissions queries permission status via the Permissions API.

permissions tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful