Java Reference
In-Depth Information
What if you want to check the version and then redirect to a different page if it's a version that is earlier
than your page requires?
With ActiveX controls there's no easy way of using JavaScript code to check the ActiveX control version.
One way is to fi nd a property that the new control supports but that older versions don't, and then com-
pare that to null. For example, imagine you have a control whose latest version introduces the property
BgColor. To check if the installed version is the one you want, you type the following:
if (document.myControl.BgColor == null)
{
alert(“This is an old version”);
}
It's also possible that the ActiveX creator has added to his control's object a version property of some
sort that you can check against, but this will vary from control to control.
Plug-ins
With plug-ins you need to make use of the Plugin objects in the navigator object's plugins[] array
property. Each Plugin object in the array has a name, filename, and description property, which
may provide version information. However, this will vary between plug-ins.
For example, for Flash Player 10 on Win32, the description for the following code is Shockwave Flash
10.0 r12.
navigator.plugins[“Shockwave Flash”].description
Using regular expressions, which were introduced in Chapter 9, you could extract the version number
from this string:
var myRegExp = /\d{1,}.\d{1,}/;
var flashVersion = navigator.plugins[“Shockwave Flash”].description;
flashVersion = parseFloat(flashVersion.match(myRegExp)[0]);
The fi rst line of code defi nes a regular expression that matches one or more digits, followed by a dot, and
then one or more numbers. Next, you store the description of the Flash plug-in in the variable flashVersion.
Finally you search the variable for the regular expression, returning an array of all the matches made. Then
use the parseFloat() function on the contents of the element in the array at index 0 (in other words, the
fi rst element in the array).
Changes to Internet Explorer 6 Service Pack 1b and ActiveX Controls
For mostly legal reasons, Microsoft made changes to how ActiveX controls work in IE. Whenever a user
browses to a page with an ActiveX control, she gets a warning about the control, and by default it's
blocked unless she chooses to unblock it. There are two ways around this:
1.
Don't access any external data or have any <param/> elements in the defi nition, as the follow-
ing example demonstrates:
<object classid=”CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6”></object>
Search WWH ::




Custom Search