|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
If you have developed an inline VRML scene to embed in a Web page, for instance, you might want to know whether the user has a plug-in installed that supports VRML. Then, a VRML world or a representative GIF image could be displayed, as appropriate, such as the following: <SCRIPT LANGUAGE=JavaScript> <!-- Hide script from incompatible browsers --> var isVrmlSupported,VrmlPlugin isVrmlSupported = navigator.mimeTypes[x-world/x-vrml] if (isVrmlSupported) document.writeln(<EMBED SRC=world.wrl HEIGHT=200 WIDTH=400>) else document.writeln(<IMG SRC=world.gif HEIGHT=200 WIDTH=400>) // Hide script from incompatible browsers --> </SCRIPT>
Including and Referencing Plug-in ObjectsThe first step in using plug-ins within a Web page is to include them in the first place. The recommended way to do this is to use the <OBJECT> tag; however, both Internet Explorer and Navigator support the <EMBED> tag as well. If you want to include plug-in content in a Web page that will work with browsers that support both tags, use something like the following, which shows an example using the Flash Player by Macromedia: <OBJECT CLASSID=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 ID=objID WIDTH=100 HEIGHT=100 CODEBASE=<http://active.macromedia.com/flash2/cabs/> ⇒swflash.cab#version=2,0,0,11> <PARAM NAME=Movie VALUE=controls.swf> <EMBED NAME=objID MAYSCRIPT SRC=controls.swf WIDTH=100 HEIGHT=100 PLUGINSPAGE=<http://www.macromedia.com/shockwave/download/> ⇒index.cgi?P1_Prod_Version=ShockwaveFlash> </OBJECT>
This HTML code segment consists of the following tags:
Plug-ins included with the <OBJECT> and <EMBED> commands are also referenced differently. When included with the <OBJECT> tag, plug-in objects are members of the window object; those with <EMBED> are members of window.document. Determining Which Plug-ins Are InstalledThe navigator.plugins object has the following properties:
Listing 23.3 shows an example of a JavaScript that uses the navigator.plugins object to display the names of the installed plug-ins right on the Web page. You can place this JavaScript at the bottom of any Web page to display this information (see Figure 23.5). Listing 23.3 PlugIn.htmJavaScript to Detect Locally Installed Plug-ins <HTML> <HEAD> <TITLE>JavaScript Plug-Ins Check</TITLE> </HEAD> <BODY BGCOLOR=#FFFFFF> <H1>JavaScript Plug-Ins Check</H1> <HR> <SCRIPT LANGUAGE=JavaScript> <!-- Hide script from incompatible browsers --> var i,n n = navigator.plugins.length document.writeln(This Web browser has + n + plug-ins installed:<P>) for (i=0;i<n;i++) document.writeln(navigator.plugins[i].name + <BR>) // Hide script from incompatible browsers --> </SCRIPT> <HR> <ADDRESS> Jim ODonnell, <A HREF=mailto:odonnj@rpi.edu>odonnj@rpi.edu</A> </ADDRESS> </BODY> </HTML>
Client-Supported MIME TypesThe navigator.mimeTypes object is similar to the navigator.plugins object and can be used to determine supported MIME types at the client. It has the following properties:
Listing 23.4 shows an HTML document that contains a JavaScript that displays all the client-supported MIME types in an HTML table. Along with the MIME type, the supported file extensions are shown, as well as the name of the associated plug-in, if any (see Figure 23.6).
|
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. |