Detecting Plugins in Internet Explorer - Getting started
(Page 4 of 7 )
Detecting plug-ins in IE is not actually that difficult; ideally, you need to use VBScript. In fact, even if you use JavaScript, you still have to get the script to write the VBScript code, so for now we’ll cut out the middle-man and stick with the proprietary script language. Since you're targeting Microsoft Internet Explorer users only with the script, it will work. Please note that this article is not an article discussing cross-browser interoperability; I’m assuming that you already have a half-decent browser vendor detection and redirection or similar system. This script will only work on MSIE browsers (ideally version 6)!
It should be noted at this point also that it is not possible to detect these kinds of things using PHP, because of the way that server-side scripting works; the page is created before it is passed to the browser, so there is no way for the script on the server to get this kind of information until after the page has been created, and by then, it's too late.
So, to begin, get yourself a basic HTML page set up; we’re not worried about presentation at this stage, so the following will do:
<html>
<head>
<title>MSIE Plug-in Detection</title>
</head>
<body>
<h1>Welcome to the Plug-in Detection Page</h1>
</body>
</html>
The script is fairly long and fairly repetitive, but it is very basic considering and is easy enough to follow. Yes, there are better ways of doing it to reduce the amount of code, but again, this is not an article discussing clean and efficient code, it’s about writing a script that has a specific purpose and works.
Set the script tags in the body of the document and begin by adding the on error resume next statement:
<script type="text/vbscript">
on error resume next
The script will not work without this statement. Next, you can declare all of your variables, using the Dim statement followed by the name of each variable, but as we are including some version checking where possible, there are rather a lot of them and the script is long enough as it is. We’ll leave them out because, fortunately, variables do not have to be explicitly declared in VBScript.
Next: The heart of plug-in detection >>
More Windows Scripting Articles
More By Dan Wellman