Java Reference
In-Depth Information
Using Plug-ins and ActiveX Controls
When you have the plug-ins or ActiveX controls embedded into the page, their actual use is very uniform.
To make life easier for you, most plug-in and ActiveX developers make the properties, methods, and
events supported by each plug-in and ActiveX control similar. However, it's important to check the
developer's documentation because it's likely that there will be some idiosyncrasies.
Inside the <embed/> or <object/> element, you give your plug-in or control a unique id value. You
can then access the corresponding object's methods, properties, and events just as you would for any
other element. The actual properties, methods, and events supported by a plug-in or control will be spe-
cifi c to that control, but let's look at one of the more commonly available controls, Apple's QuickTime
player, which comes in both plug-in form for non-IE browsers and ActiveX control form for IE. You can
fi nd more information on this control at the following URL:
http://developer.apple.com/documentation/QuickTime/Conceptual/QTScripting_
JavaScript/bQTScripting_JavaScri_Document/QuickTimeandJavaScri.html
To run the examples in this chapter, you need the free QuickTime player from
http://www.apple.com/quicktime/ .
Note that you can buy a version with more features, but it is not necessary for this topic.
First, you need to embed the control in a web page. Type the following into a text editor:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Using JavaScript to Interface with Quicktime</title>
</head>
<body>
<object classid=”clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B”
codebase=”http://www.apple.com/qtactivex/qtplugin.cab”
id=”audioPlayer” width=”0” height=”0”>
<param name=”src” value=”sound1.mp3” />
<embed height=”0” width=”0” type=”audio/mpeg” src=”sound1.mp3”
pluginspage=”www.apple.com/quicktime/download”
enablejavascript=”true” name=”audioPlayer” />
</object>
<form id=”form1” name=”form1” action=”“>
<input type=”button” value=”Play” id=”buttonPlay” name=”buttonPlay”
onclick=”buttonPlay_onclick()“ />
<input type=”button” value=”Stop” id=”buttonStop” name=”buttonStop”
onclick=”buttonStop_onclick()“ />
</form>
</body>
</html>
Save this code as quicktime.htm.
The fi rst thing to note is the <embed/> element (for non-IE browsers) resides as a child of the <object/>
element. Firefox, Opera, Safari, and Chrome ignore the <object/> element and display only the plug-
in defi ned by <embed/>. IE ignores the <embed/> element within the <object/> element, even though
the browser supports <embed/>. If you placed the <embed/> element outside of <object/>, IE would
Search WWH ::




Custom Search