JavaScript Editor JavaScript Validator     JavaScript Editor 



Team LiB
Previous Section Next Section

Chapter 15: Using ActiveX and Plug-Ins with JavaScript

Overview

Although browsers like Internet Explorer and Netscape Navigator provide a lot of built-in functionality, there are many things that they can't do unaided, such as playing video clips or sound bites, and functionality of this sort is becoming more and more common on the Internet. To get around this problem, browsers can have their functionality extended by using plug-ins.

Plug-ins, as their name suggests, are downloaded and "plugged into" the browser. Hundreds of different plug-ins are available, though the more common ones include Macromedia's Flash, which plays Flash movies, and RealNetworks' Real Audio and video player, which plays real audio and media files.

Essentially, plug-ins are objects that encapsulate all the functionality they need to perform their tasks, such as playing audio files, in a way that hides the complexity from the programmer. They are usually written in languages such as C++ and Java.

Plug-ins usually, but not always, have some sort of user interface. For example, the Real Audio plug-in has a user interface that displays buttons to play, pause, and stop the playing of an audio file. (See Figure 15-1.)


Figure 15-1

Some plug-ins make objects with various methods and properties available to us. We can access these through JavaScript, in a similar manner to how we access the methods and properties of the window object or the Math object. For example, the RealOne player plug-in makes available the DoPlay() method that we can use to play a sound clip.

I guess you're not going to be shocked to find out that IE and NN do things differently.

Netscape has supported plug-ins since NN 3.0. Note that earlier versions of Netscape 6 had some problems with plug-ins, so the code in this chapter may not work on this browser but is fine on Netscape 6.1+ and Netscape 7.

IE does not support plug-ins, but IE 4.0+ running on Windows does support ActiveX controls, which provide the same functionality as plug-ins.

Fortunately, as we'll see, using ActiveX controls and Netscape plug-ins is similar, and with a few tweaks can be done with almost the same code. The main difference is actually making sure that the plug-in or ActiveX control is available for use and ready to run in the user's browser in the first place. We'll cover this problem in more detail for NN and IE before going on to discuss using the plug-ins and ActiveX controls.


Team LiB
Previous Section Next Section


JavaScript Editor JavaScript Validator     JavaScript Editor


©