Reputation: 73
Our site tries to detect support for the application/pdf
mimetype via a check like this:
function isPdfMimeTypeSupported() {
if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0)
for (i = 0; i < navigator.mimeTypes.length; i++) {
var mtype = navigator.mimeTypes[i];
if (mtype.type == "application/pdf" && mtype.enabledPlugin)
return true;
}
return false;
}
This works as expected in Chrome however in Microsoft Edge the mimeTypes collection only has two entries:
The check fails and we are incorrectly warning the user that their browser doesn't support PDF.
If there a way to check for PDF support in JavaScript that works in Edge?
Upvotes: 7
Views: 24113
Reputation: 268364
Important: The following answer is relevant only for a specific period of time
Microsoft Edge, as suggested above, ships with native PDF viewing support built-in. I don't believe there are any versions of Edge that lack this functionality, but if there are, they would be very rare.
We are currently planning to update navigator.mimeType
in the near future, which will cause your present approach (as presented above) to begin working. Until that time, I would encourage you to (I feel terrible for suggesting this) sniff the user-agent string.
This issue will be resolved in a future update to Microsoft Edge.
Upvotes: 5
Reputation: 6884
Check which version of Windows 10 you are using.
If you are using an N edition, then PDF support is not available out-of-the-box, and you'll need to install the Windows 10 Media Feature Pack or Acrobat.
For more information see Windows N editions explained
Upvotes: 1