Detecting "application / pdf" support in Microsoft Edge

Our site is trying to detect support for a tag like application/pdf by checking:

 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, but in Microsoft Edge, the mimeTypes collection has only two entries:

  • "application / x-shock flash"
  • "app / FutureSplash"

Validation fails, and we incorrectly warn the user that their browser does not support PDF.

If there is a way to test PDF support in JavaScript that works in Edge?

+6
source share
2 answers

Important: The following answer only applies to a specific time period.

Microsoft Edge, as suggested above, comes with built-in support for viewing PDF files. I do not think that there are any versions of Edge that do not have this feature, but if they are, they will be very rare.

In the near future, we plan to update navigator.mimeType , which will lead to the fact that your current approach (as presented above) will start working. Until then, I would like to urge you (I feel terrible for that), sniffing the user-agent string.

This issue will be resolved in a future Microsoft Edge update.

+5
source

Check which version of Windows 10 you are using.

If you are using version N, then PDF support is not available out of the box, and you will need to install Windows 10 Media Feature Pack or Acrobat .

See Windows N explanations for more information.

+1
source

All Articles