Javascript获得MIME类型支持 [英] Javascript get MIME type support
问题描述
我发现了如何从navigator.mimeTypes获取模仿类型:
I found how to get mimetypes from navigator.mimeTypes:
function GetMimeTypes() {
var message = "";
var mimes = navigator.mimeTypes;
for (var i = 0; i < mimes.length; i++) {
message += "<b>" + mimes[i].type + "</b> : " + mimes[i].description + "/" + mimes[i].suffixes + "<br />";
}
var info = document.getElementById("mime");
info.innerHTML = message;
}
,但不会返回类似的类型 text/html,text/css或text/javascript.我发现:自然地,几种MIME类型由浏览器本身处理,例如文本/javascript(JavaScript文件),文本/css(CSS样式表),图像/gif(GIF编码图像),图像/jpegimages,文本/xml(XML文件)和text/html(HTML文件).但是,还有许多其他问题是由插件和检查程序navigator.mimeTypes ["text/html"]!= null处理的,如何获得这些列表?
but it doesn't return types like text/html, text/css or text/javascript. I found: Naturally,several MIME types are handled by the browser itself, such as text/javascript(JavaScript files), text/css (CSS style sheets), image/gif (GIF-encoded images), image/jpegimages),text/xml (XML files), and text/html(HTML files). Many others, however, are handled by plugins and checker navigator.mimeTypes["text/html"] != null, how can i get list of these?
推荐答案
在Google Chrome/Firefox中使用您的代码,我得到:
Using your code in Google Chrome/Firefox I get:
application/vnd.chromium.remoting-viewer : /
pepper-application/x-chromoting : /
application/x-nacl : Native Client Executable/nexe
application/pdf : Portable Document Format/pdf
application/x-google-chrome-print-preview-pdf : Portable Document Format/pdf
application/x-shockwave-flash : Adobe Flash movie/swf
...
etc.
如果您使用的是Internet Explorer,那么很遗憾,不支持navigator.mimeTypes.
If you're using Internet Explorer, then navigator.mimeTypes is not supported unfortunately.
请参见下面的链接,以确认您无法从IE获取模仿类型列表: http://www.howtocreate.co.uk/wrongWithIE/?chapter=navigator .plugins
See the link below for confirmation that you cannot get a list of mimetypes from IE: http://www.howtocreate.co.uk/wrongWithIE/?chapter=navigator.plugins
这篇关于Javascript获得MIME类型支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!