O'Reilly Network Script Library
The script makes it easy to check for the existence of 5 commonly-used plug-ins: Apple's QuickTime, Macromedia's Flash and Shockwave for Director, Real Networks' RealPlayer, and Microsoft's Windows Media Player.
The script can also be used to redirect the browser to a new page if a given plug-in is (or is not) found.
Finally, the script reports whether detection is or is not possible.
Note that for some plug-ins, such as Flash and QuickTime, it is possible to check not only for the plug-in's existence, but for a specific version of the plug-in. However, version information is detected with greater ease and reliability from within a plug-in file. Further, that level of detail would add significantly to the size and complexity of this script. For these reasons, version detection is not included in this script.
Copy the contents of the script between the
</HEAD> tags in your document. (Since we're using multiple
<SCRIPT> blocks, it would require two separate .js files and wouldn't work for Netscape 3, so it makes more sense to just include the script in your document.)
To check for a given plug-in, simply call one of the following functions, which return a value of either
true (if the plug-in is there) or
false (if the plug-in is not there or could not be detected):
For example, to check for the existence of the QuickTime plug-in, you could do the following:
var quickTimeIsInstalled = detectQuickTime();
alert('You have the QuickTime plug-in.');
Once you know if the plug-in is installed, there are several things you can do:
<EMBED> tags that pull the plug-in content if the plug-in was found).
- If you pass the function a URL, it will redirect to that URL if the plug-in is not found:
- If, instead, you want to redirect if the plug-in is found, pass the function both a URL and the word
Finally, if you simply want to find out if detection is possible at all, do the following:
var ableToDetect = canDetectPlugins();
alert('It is possible to check for plug-ins.');