Check Browser Support for specific Mime Type?

岁酱吖の 提交于 2019-12-04 23:42:08

In recent browsers there are navigatior.plugins array-like object. You can check each plugin for your mime type.

Here is the solution gist and jsfiddle.

var mimeCheck = function (type) {
    return Array.prototype.reduce.call(navigator.plugins, function (supported, plugin) {
        return supported || Array.prototype.reduce.call(plugin, function (supported, mime) {
            return supported || mime.type == type;
        }, supported);
    }, false);
};

You could make an AJAX call and check response headers for mimetype.

 $.ajax({
    type: "GET",
    url: 'http://..../thing.pdf',
    success: function (output, status, xhr) {
      alert("done!"+ xhr.getAllResponseHeaders());
      alert("done!"+ xhr.getResponseHeader("Content-Type"));
    }
  });
Fez Vrasta

In this question there was the same question I think, try to check out it

Check if a browser supports a specific MIME type?

Aivar

If you define which plugin is needed for specific document type, then you may try to look if needed plugin exists. Should work at least on Firefox and Chrome. window.navigator.plugins

And here is a nice example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!