|
Properties of the mimeTypes ObjectA mimeTypes object, as found in the mimeTypes array (as an element), features the following properties:
Example 30-1 shows a list of the MIME types supported by the browser, including all three string properties of each mimeTypes object.
<HTML> <HEAD> <TITLE>Supported MIME types</TITLE> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- // notice that you do not have to issue </TH> and </TD> tags! document.write("<TABLE BORDER=1><TR VALIGN=TOP>" + "<TH ALIGN=left><I>i</I>" + "<TH ALIGN=left><I>type</I>" + "<TH ALIGN=left><I>description</I>" + "<TH ALIGN=left><I>suffixes</I></TR>") for (var I = 0; i < navigator.mimeTypes.length; ++i) { document.writeln("<TR VALIGN=TOP><TD>" + i + "<TD>" + navigator.mimeTypes[i].type + "<TD>" + navigator.mimeTypes[i].description + "<TD>" + navigator.mimeTypes[i].suffixes + "</TR>") } document.writeln("</TABLE>") // --> </SCRIPT> </BODY> </HTML>
Example 30-1. We use tables to organize the list of supported MIME types. Try loading Example 30-1 in your browser. You should see a fairly long list of MIME types. Figure 30-1 shows the beginning of the list as it appeared on our computer. Notice that in Example 30-1 we referred to elements of the mimeTypes array by indexes. You can also use the MIME type’s name as shown earlier in this chapter. Here are a few examples:
navigator.mimeTypes["image/jpeg"].type navigator.mimeTypes["image/jpeg"].description navigator.mimeTypes["image/jpeg"].suffixes
Properties of the plugins ObjectThe plugins object features the following properties:
The following statement, for example, assigns shorthand variables for the predefined Shockwave properties:
var myPlugin = navigator.plugins["Shockwave"].name var myPluginFile = navigator.plugins["Shockwave"].filename var myPluginDesc = navigator.plugins["Shockwave"].description
Example 30-2 lists the installed plug-ins, including each plug-in’s name, filename, description, and MIME types that it handles.
<HTML> <HEAD> <TITLE>Installed plug-ins</TITLE> </HEAD> <BODY> <SCRIPT LANGUAGE="JavaScript"> <!-- // notice that you do not have to issue </TH> and </TD> tags! document.write("<TABLE BORDER=1>") for (i = 0; i < navigator.plugins.length; ++i) { document.writeln("<TR><TD><FONT SIZE=2>"+ "<U><B>" + navigator.plugins[i].name + "</B></U><BR>" + "<U>Filename:</U> " + navigator.plugins[i].filename + "<BR>" + "<U>Description:</U> " + navigator.plugins[i].description + "<BR>" + "<U>MIME types:</U> ") for (var j = 0; j < navigator.plugins[i].length; ++j) { document.write(navigator.plugins[i][j].type + "; ") } document.write("</FONT></TD></TR>") } document.write("</TABLE>") // --> </SCRIPT> </BODY> </HTML>
Example 30-2. We use the navigator.plugins to list the installed plug-ins and their properties. Figure 30-2 shows the exact output of Example 30-2 on our PC. The following statement assigns the string "LiveAudio" to a variable:
var audioPlugin = navigator.mimeTypes["audio/basic"].enabledPlugin.name
The name property belongs to a plugins object, because navigator.mimeTypes["audio/basic"].enabledPlugin is equivalent to navigator.plugins["LiveAudio"]. LiveAudio and LiveVideoLiveAudio and LiveVideo are plug-ins that come built into Netscape Navigator 3.0x and above. LiveAudio enables you to embed audio in a Web page, whereas LiveVideo supports various video formats. Since both LiveAudio and LiveVideo are plug-ins, you include them in an HTML document via the standard <EMBED> tag. LiveAudioLiveAudio plays audio files in WAV, AIFF, AU, and MIDI formats. Audio controls appear according to the size specified in the WIDTH and HEIGHT parameters in the <EMBED> tag. You can create an audio console with any of the following views:
|
|||||||||||||||||||||||
With any suggestions or questions please feel free to contact us |