Java Reference
In-Depth Information
break;
}
}
The for loop iterates through the navigator.plugins collection, starting from index 0 and continuing
up to the last element. Each plug-in in the collection has its name property checked to see if it contains
the text quicktime . If it does, you know QuickTime is installed and break out of the loop; if not,
QuickTime is clearly not installed.
An alternative to using navigator object's plugins[] collection is using the navigator object's
mimeTypes[] , which is a collection of mimeType objects representing the MIME types supported by the
browser. You can use this array to check whether the browser supports a specifi c type of media.
You have already come across MIME types before — the type attribute of the <embed/> element can
be used to specify a MIME type so that the browser knows which plug-in to embed. Again, using the
Installed plug-ins page can give you the MIME types for a particular plug-in. In fact, one plug-in may
well support more than one MIME type. When you check for a particular MIME type, you are checking
that the browser supports a particular type of fi le format rather than necessarily a particular plug-in.
For example, you may use the mimeTypes array to check for the Flash plug-in as follows:
if (navigator.mimeTypes[“application/x-shockwave-flash”] &&
navigator.mimeTypes[“application/x-shockwave-flash”].enabledPlugin)
{
window.location.replace(“my_flash_enabled_page.htm”);
}
else
{
window.location.replace(“my_non_flash_page.htm”);
}
The if statement's condition has two parts separated by the AND operator &&.
The fi rst part checks that the specifi ed MIME type is supported by trying to access a specifi c mimeType
object in the mimeTypes collection. If there such object exists, then undefined is returned, which eval-
uates to false.
The second part of the condition checks to see if a plug-in to handle this MIME type is enabled. Although
unusual, it is possible for a MIME type to be supported, or recognized, by the browser, but for no plug-
in to be installed. For example, if the user has Microsoft Word installed, the MIME type application/
msword would be valid, but that does not mean a plug-in exists to display it in the browser! The
enabledPlugin property of the mimeType object actually returns a Plugin object unless it does not exist.
Checking for and Embedding ActiveX
Controls on Internet Explorer
Although IE does support plug-ins to a certain extent, its support for ActiveX controls is more complete.
The main difference between an ActiveX control and a plug-in is how they are embedded into a page and
how they are installed. Once they are embedded and installed, their use, as far as scripting goes, will be
very similar to that for plug-ins.
Search WWH ::




Custom Search