This is an interesting problem.
Actually the official definition of Javascript 1.1 knows an object 'mimeTypes' which is located beneath the 'navigator' object, and adressed as 'navigator.mimeTypes[...]'. So the following html-code should show all known mime types, including the Celestia 'cel' and 'celx' type:
Code: Select all
<html>
<head>
<title>Mime Type Test</title>
</head>
<body>
<b>The following Mime Types are known:</b>
<script type="text/javascript">
<!--
for(var i=0; i<navigator.mimeTypes.length; ++i)
document.write("<br>" + navigator.mimeTypes[i].type);
//-->
</script>
</body>
</html>
And the following html-code should report if Celestia is available on that computer:
Code: Select all
<html>
<head>
<title>Celestia Existence Test</title>
<script type="text/javascript">
<!--
if (navigator.mimeTypes["application/celestia"])
alert("Celestia is available on this computer!");
else
alert("Celestia is not available!");
//-->
</script>
</head>
<body>
Celestia Existence Test
</body>
</html>
Unfortunately every browser is playing his own game here:
- IE knows the 'mimeType' object only for compatibility reasons, but always leaves it empty.
- Gecko engine browsers (Netscape 6 and 7, Mozilla and Firefox) only list those mime types for which there exists real browser plugins (which is not the case for cel and celx, but also - for example - jpeg).
- Opera and Netscape 4 are actually the only browsers which interprets the above examples according to the standard.
Though I like using the Firefox browser, it's Javascript compatibility seems quite lousy (instead there is an increasing plugin hype).
maxim