JavaScript Navigator pdfViewerEnabled Property

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline

What You’ll Learn

navigator.pdfViewerEnabled is a read-only Boolean that tells you whether the browser can show PDF files inline. Learn the MDN check pattern, how it replaces legacy MIME sniffing, UI messaging when PDFs download instead, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

Boolean

03

Baseline

Widely available

04

true

Inline PDF OK

05

false

Download / external

06

Replaces

Legacy PDF sniffing

Introduction

Many apps link to invoices, manuals, or reports as PDF files. Users expect either an in-browser preview or a download. Guessing that behavior from old plugin / MIME lists was fragile.

navigator.pdfViewerEnabled answers one clear question: can this browser display PDFs inline when navigating to them? If not, the PDF is downloaded and may open in an external application.

💡
Modern replacement

MDN: this property replaces several legacy ways of inferring inline PDF support. Prefer it over digging through navigator.mimeTypes for application/pdf.

Understanding the pdfViewerEnabled Property

Think of it as a green / red light for inline PDF viewing. You read it once (or when choosing UI copy) — you never assign to it.

  • true — browser can show PDFs inline (built-in viewer or PDF extension).
  • false — navigating to a PDF downloads it (external app may handle it).
  • Read-only — part of the HTML Navigator interface.
  • Baseline — Widely available across modern browsers (MDN, since March 2023).

📝 Syntax

General form of the property:

JavaScript
navigator.pdfViewerEnabled

Value

  • A Boolean indicating whether inline PDF viewing is supported.

Common patterns

JavaScript
// MDN pattern:
if (!navigator.pdfViewerEnabled) {
  // The browser does not support inline viewing of PDF files.
}

// Positive branch:
if (navigator.pdfViewerEnabled) {
  console.log("Inline PDF viewing looks available");
}

⚡ Quick Reference

GoalCode
Read the flagnavigator.pdfViewerEnabled
No inline PDF?if (!navigator.pdfViewerEnabled) { … }
Inline PDF OK?if (navigator.pdfViewerEnabled) { … }
Typetypeof navigator.pdfViewerEnabled === "boolean"
Writable?No (read-only)
Status (MDN)Baseline Widely available

🔍 At a Glance

Four facts to remember about navigator.pdfViewerEnabled.

Returns
boolean

true / false

Baseline
widely

Since March 2023

Access
read-only

No assignment

Best for
PDF UX

Inline vs download

📋 pdfViewerEnabled vs mimeTypes

navigator.pdfViewerEnablednavigator.mimeTypes PDF check
QuestionCan PDFs open inline?Is application/pdf listed?
API shapeSimple BooleanMimeTypeArray membership
MDN guidancePreferred for new codeLegacy / secondary signal
Typical useChoose link / embed UXOlder detection scripts
Use together?Optional for debugging — make production PDF decisions with pdfViewerEnabled

Examples Gallery

Examples follow MDN navigator.pdfViewerEnabled patterns. Prefer Try It Yourself to inspect your browser. Use View Output for expected messaging.

📚 Getting Started

Read the Boolean and apply the MDN check.

Example 1 — Read pdfViewerEnabled

Log the current Boolean value.

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

How It Works

Most modern desktop browsers return true. Some locked-down or minimal environments return false.

Example 2 — MDN if (!pdfViewerEnabled) Check

Branch when inline PDF viewing is not supported.

JavaScript
if (!navigator.pdfViewerEnabled) {
  console.log("Inline PDF viewing not supported");
} else {
  console.log("Inline PDF viewing looks available");
}
Try It Yourself

How It Works

This is MDN’s recommended shape: treat false as “expect download / external handling.”

📈 Practical Patterns

User messaging, legacy comparison, and a reusable helper.

Example 3 — Friendly UI Message

Build copy for a docs / invoice download button.

JavaScript
const msg = navigator.pdfViewerEnabled
  ? "PDF will open in the browser when possible."
  : "PDF will download — open it with a PDF app.";
console.log(msg);
Try It Yourself

How It Works

Set expectations before the click so a download does not feel like a broken preview.

Example 4 — Compare with Legacy mimeTypes

See how the modern flag relates to the old PDF MIME check.

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

console.log("pdfViewerEnabled: " + pdfEnabled);
console.log("mimeTypes has application/pdf: " + Boolean(mimePdf));
console.log("Prefer pdfViewerEnabled for new PDF UI decisions");
Try It Yourself

How It Works

They often agree on modern browsers. Still use pdfViewerEnabled as the primary decision API.

Example 5 — Status Helper for Links / Embeds

Return a small object you can reuse in UI components.

JavaScript
function pdfViewStatus() {
  const inline = Boolean(navigator.pdfViewerEnabled);
  return {
    inline,
    suggestedTarget: inline ? "_blank" : "_self",
    tip: inline
      ? "Open PDF in a new tab for an inline preview."
      : "Expect a download; offer a clear Download PDF label."
  };
}

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

How It Works

Keep the Boolean as the source of truth; derive labels and link targets from it.

🚀 Common Use Cases

  • Invoice / report links — label buttons as “View PDF” vs “Download PDF.”
  • Docs hubs — prefer embed / new-tab preview when inline viewing is available.
  • Help text — warn when the browser will download instead of preview.
  • Migration — replace mimeTypes-based PDF sniffing with this Boolean.
  • Diagnostics — include pdfViewerEnabled in support debug panels.

🧠 How navigator.pdfViewerEnabled Works

1

Read the property

Access navigator.pdfViewerEnabled in your script.

Read
2

Browser reports capability

Returns true if inline PDF viewing is supported.

Boolean
3

Branch your UX

Choose preview, new-tab, or download-oriented messaging.

UX
4

Skip legacy sniffing

Prefer this flag over old mimeTypes / plugin checks.

📝 Notes

  • Baseline Widely available (MDN, since March 2023).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Read-only Boolean on Navigator.
  • Replaces several legacy methods of inferring inline PDF support.
  • Headers and user settings can still affect a specific PDF response.
  • Related: mimeTypes, oscpu, Window, JavaScript hub.

Universal Browser Support

navigator.pdfViewerEnabled is Baseline Widely available across modern browsers (MDN: since March 2023). Use it as the primary check for inline PDF viewing support.

Baseline · Widely available

Navigator.pdfViewerEnabled

Read the Boolean to choose View vs Download messaging. Prefer it over legacy mimeTypes PDF sniffing.

Universal Widely available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer Not a Baseline target for this property
Unavailable
pdfViewerEnabled Excellent

Bottom line: Check navigator.pdfViewerEnabled, warn when false, and keep production PDF UI decisions on this Baseline Boolean.

Conclusion

navigator.pdfViewerEnabled is a simple, Baseline Boolean for inline PDF viewing. Use the MDN if (!navigator.pdfViewerEnabled) pattern to set expectations, and prefer it over legacy mimeTypes sniffing.

Continue with permissions, mimeTypes, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Check before choosing View vs Download labels
  • Prefer this over mimeTypes PDF membership checks
  • Explain downloads clearly when the flag is false
  • Keep PDF links accessible either way
  • Test with real PDF URLs in your target browsers

❌ Don’t

  • Assume true overrides Content-Disposition: attachment
  • Build new detection on plugin / mimeTypes lists alone
  • Try to assign to pdfViewerEnabled
  • Block access to the PDF file when the flag is false
  • Confuse this with a PDF.js or third-party embed library check

Key Takeaways

Knowledge Unlocked

Five things to remember about pdfViewerEnabled

Baseline Boolean — inline PDF viewing or download.

5
Core concepts
02

true

Inline PDF OK

Preview
📥 03

false

Download / external

Fallback
🔒 04

Access

read-only

API
🎯 05

Status

Baseline

Modern

❓ Frequently Asked Questions

It is a read-only Navigator property that returns a Boolean: true when the browser can display PDF files inline (built-in viewer or a PDF viewer extension), false when navigating to a PDF will download it instead (and an external app may handle it).
No. MDN marks it as Baseline Widely available (since March 2023). It is a standard HTML Navigator property — not Deprecated, Experimental, or Non-standard.
MDN’s pattern: if (!navigator.pdfViewerEnabled) { /* browser does not support inline PDF viewing */ }.
For new code, prefer pdfViewerEnabled. MDN notes it replaces several legacy ways of inferring inline PDF support (including mimeTypes-based checks).
It means the browser supports inline PDF display when navigating to a PDF. Individual sites, Content-Disposition headers, or user settings can still change how a specific file is handled.
No. The property is read-only. You read the Boolean; you do not assign to it.
Did you know?

Before pdfViewerEnabled, sites often probed plugins or navigator.mimeTypes["application/pdf"]. Those signals became noisy as browsers reduced plugin APIs for privacy and security — this Boolean is the clean replacement.

Learn permissions Next

Permissions API entry point for granted / prompt / denied.

permissions →

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.

8 people found this page helpful