↑
Main Page
Detecting Plugins
Detecting Plugins
As with most Web technology, two types of plugins are available: those from Microsoft and those from
others. The Microsoft way uses ActiveX technology, which you may remember as the way to create
XML-related objects; the other way has been called
Netscape-style plugins
because Netscape Navigator
introduced the concept of plugins to the Web. Until recently, Internet Explorer supported Netscape-style
plugins in addition to ActiveX controls. Beginning with Internet Explorer 5.5 Service Pack 2 (Windows
only), however, Microsoft eliminated support for the Netscape-style plugins.
The main difference between the two types of plugins is the architecture. ActiveX plugins are built on
Microsoft’s ActiveX platform whereas Netscape-style plugins are built on top of the Netscape Plugin
API. Originally, every browser (including Internet Explorer) was forced to support the Netscape-style
plugins because Netscape was the dominant browser and only compatible browsers could compete.
Although many will speculate why Microsoft ended support for Netscape-style plugins, it has created
a clear rift in the world of plugins. Many plugin developers are required to create both Netscape-style
plugins and ActiveX wrappers for these plugins in order to support Internet Explorer.
Today, browsers are separated into those that don’t support Netscape-style plugins (such as Internet
Explorer on Windows) and those that do (such as Mozilla, Opera, Safari, and many other browsers).
Because of these differences, you have different ways of detecting whether a plugin is installed on a
given browser.
Detecting Netscape-style plugins
Since Netscape 3.0, many browsers (notably those based on Mozilla) allow JavaScript to determine
which MIME types are mapped to plugins, ultimately enabling you to determine if a given plugin is
installed. This is determined through the help of the
window.mimeTypes
collection.
Two types of Netscape-style plugins exist: the style used in Netscape 4.x and the newer Gecko style used
in Mozilla. The details of the differences are of no consequence to JavaScript developers because both
styles are accessed the same way.
Each MIME type registered to a plugin is present in
window.mimeTypes
, indexed both by number and
by MIME type, allowing you to access a MIME type directly or to iterate through the collection. An
object with four properties represents each MIME type:
?
description
— A description of the type of file represented by the MIME type
?
enabledPlugin
— Reference to a plugin object with information about the specific plugin
?
suffixes
— The file suffixes associated with this MIME type (such as mapping
.gif
to
image/gif
)
?
type
— The MIME type
You can print out a list of all visible MIME types and their descriptions by running a simple script:
<html>
<head>
<title>MIME Types Example</title>
535
Interacting with Plugins
21_579088 ch18.qxd 3/28/05 11:43 AM Page 535
Free JavaScript Editor
Ajax Editor
©
→