↑
Main Page
MIME type
</head>
<body>
<script type=”text/javascript”>
if (navigator.mimeTypes) {
document.writeln(“<h3>Supported MIME Types:</h3>”);
document.writeln(“<ul>”);
for (var i=0; i < navigator.mimeTypes.length; i++) {
document.writeln(“<li>” + navigator.mimeTypes[i].type + “ (“
+ navigator.mimeTypes[i].description + “, “
+ navigator.mimeTypes[i].suffixes + “)</li>”);
}
document.writeln(“</ul>”);
}
</script>
</body>
</html>
This example doesn’t print out any information about
enabledPlugin
, which is another object with
another set of properties:
?
description
— A description of the plugin
?
filename
— The plugin filename
?
length
— The number of MIME types associated with the plugin
?
name
— The name of the plugin
It’s worth noting that not every MIME type has a plugin associated with it, meaning that
enabledPlugin
can be
null
. The example can be updated to include plugin information keeping this in mind:
<html>
<head>
<title>MIME Types Example</title>
</head>
<body>
<script type=”text/javascript”>
if (navigator.mimeTypes) {
document.writeln(“<h3>Supported MIME Types:</h3>”);
document.writeln(“<ul>”);
for (var i=0; i < navigator.mimeTypes.length; i++) {
document.writeln(“<li>” + navigator.mimeTypes[i].type + “ (“
+ navigator.mimeTypes[i].description + “, “
+ navigator.mimeTypes[i].suffixes + “)</li>”);
if (navigator.mimeTypes[i].enabledPlugin) {
var oPlugin = navigator.mimeTypes[i].enabledPlugin;
document.writeln(“<ul>”);
document.writeln(“<li>Name: “ + oPlugin.name + “</li>”);
document.writeln(“<li>” + oPlugin.description + “</li>”);
document.writeln(“<li>MIME types supported: “
+ oPlugin.length + “</li>”);
536
Chapter 18
21_579088 ch18.qxd 3/28/05 11:43 AM Page 536
Free JavaScript Editor
Ajax Editor
©
→