|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Listing 23.4 MimeType.htmJavaScript to Detect Locally Supported MIME types <HTML> <HEAD> <TITLE>JavaScript MIME Types Check</TITLE> </HEAD> <BODY BGCOLOR=#FFFFFF> <H1>JavaScript MIME Types Check</H1> <HR> <SCRIPT LANGUAGE=JavaScript> <!-- Hide script from incompatible browsers --> var i,n n = navigator.mimeTypes.length document.writeln(The following MIME types are recognized:<P>) document.writeln(<TABLE BORDER WIDTH=100%>) document.writeln(<TR><TH COLSPAN=2>MIME Type</TH></TR>) document.writeln(<TR><TH>Extensions</TH><TH> + Associated Plug-In (if any)</TH></TR>) for (i=0;i<n;i++) if (navigator.mimeTypes[i].enabledPlugin) document.writeln(<TR><TD COLSPAN = 2><B> + navigator.mimeTypes[i].type + </B></TD></TR><TR><TD> + navigator.mimeTypes[i].suffixes + </TD><TD> + navigator.mimeTypes[i].enabledPlugin.name + </TD></TR> ) else document.writeln(<TR><TD COLSPAN = 2><B> + navigator.mimeTypes[i].type + </B></TD></TR><TR><TD> + navigator.mimeTypes[i].suffixes + </TD><TD></TD></TR> ) document.writeln(</TABLE>) // Hide script from incompatible browsers --> </SCRIPT> <HR> <ADDRESS> Jim ODonnell, <A HREF=mailto:odonnj@rpi.edu>odonnj@rpi.edu</A> </ADDRESS> </BODY> </HTML>
Calling Plug-in Functions from JavaScriptFor plug-in variables and methods to be accessible from JavaScript and Java applets, the plug-in must be LiveConnect compatible and associated with the netscape.plugin.Plugin Java class. If that is true, the plug-in variables and methods are available to JavaScriptin much the same way as the public variables and methods of Java applets are available. JavaScript gives you two ways to access and control compatible plug-ins active in the Web environment. Similar to Java applets, the first is to use the NAME attribute of the <EMBED> tag to give a name to the embedded document. This enables the plug-ins functions to be accessed through the document object. If NAME=myenvoydoc is used with the <EMBED> tag to embed an Envoy document using the Envoy Plug-In Viewer, for example, you can access the viewer functions by using the document.myenvoydoc object. It is possible to access plug-ins even if they are not named by using the embeds array of the document object. If an Envoy document is the first embedded document in the Web page, it can be accessed with document.embeds[0]. Figure 23.7 shows a simple example from the Netscape site of an HTML forms button that calls a JavaScript used to start the LiveAudio plug-in. The plug-in content is included in the Web page with the following HTML code: <EMBED SRC=suspens1.wav HIDDEN=TRUE NAME=Mysound MASTERSOUND AUTOSTART=yes LOOP=NO > The JavaScript used to interface with the plug-in is <input type=button value=Play Sound onClick=document.Mysound.play(false)> <input type=button value=Stop Sound onClick=document.Mysound.stop()> This example can be found at the following location on the Netscape site: http://developer.netscape.com:80/docs/technote/javascript/liveconnect/js_plugin.html.
Using JavaScript to Control the Shockwave Flash PlayerOne of the more popular types of multimedia content to include in a Web page is content created for Shockwave using one of Macromedias applications, such as Macromedia Director, Authorware, or FreeHand. Typically, Shockwave content is displayed using the Macromedia Shockwave Flash Player. This free player gives the user a number of options for viewing the content. You can also make use of the methods of the Shockwave Flash Player to control precisely how your Shockwave for Director movie, for example, appears to your users. This is done by including JavaScripts that respond to timers or user input to control the display of your movie through the Flash Player. Following is a list of some of the more useful methods available from the Shockwave Flash Player:
For more information on Macromedia Shockwave, you can visit their Web site at http://www.macromedia.com. You can find more specific information on controlling the Flash Player in your Web pages at http://www.macromedia.com/support/flash/.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |