In this chapter we looked at how we can use plug-ins and ActiveX controls to extend a browser's functionality. We saw that
Internet Explorer supports ActiveX controls on Windows operating systems and to some extent plug-ins. Netscape Navigator has good support for plug-ins but does not support ActiveX controls.
Most creators of plug-ins also provide an ActiveX control equivalent. Internet Explorer and Netscape Navigator are incompatible as far as the installation of plug-ins and ActiveX controls goes.
Plug-ins are embedded in a web page using the <embed> tag. We let NN know which plug-in is to be embedded by either specifying a source file or a MIME type using the src and type attributes of the <embed> tag. If we define a value for the <embed> tag's pluginspage attribute, users who don't have that plug-in installed will be able to click a link and install it.
We can find detailed information about what plug-ins are installed on our NN browser, their names, descriptions, and types, by using the About Plug-ins option on the Help menu.
To use script to check if a user has a certain plug-in, we can use the navigator object's plugins[] array property. For each plug-in installed, there will be a Plugin object defined in this array. Each Plugin object has the properties name, description, filename, and length, which we can use to determine if a plug-in exists on the user's computer. We can also use the navigator object's mimeTypes[] array property to check if a certain type of file is supported.
Internet Explorer supports ActiveX controls as an alternative to plug-ins. These are embedded into a web page using the <object> tag. We specify which ActiveX control we want by using the classid attribute. If we want to have controls automatically install for users who don't have a particular control already installed, we need to specify the codebase attribute.
Any parameters particular to the control are specified using the <param> tag, which is inserted in between the opening and closing <object> tags.
We can check if a control has loaded successfully using the readyState property of the Object object, which returns a number: 0 if the control not installed, 1 if it's still loading, and 4 if it's installed and ready for use.
Virtually every different type of plug-in and ActiveX control has its own interface, for which the control's documentation will provide the details. We looked briefly at the RealPlayer control by RealNetworks.
We also saw that while plug-ins and controls are great for extending functionality, they are subject to potential pitfalls. These include differences in the way plug-ins and ActiveX controls are scripted, differences in operating systems, and differences between versions of the same plug-in or control.
In the next chapter we change direction slightly to look at how script can be used on the web server rather than the browser. We'll look at how to set up your own web server, and how we can use JavaScript to control the web server and dynamically create pages on the fly.