|
|
|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98
CHAPTER 23 Finding Records Is Sometimes Difficult
by Jim O'Donnell
- In this chapter
- What Are Web Browser Objects? 560
- Referencing Web Browser Objects 561
- Netscapes LiveConnect 563
- The Netscape Packages 565
- JavaScript to Java Communication 565
- Java to JavaScript Communication 568
- JavaScript and Plug-Ins 569
- Using JavaScript to Control the Shockwave Flash Player 574
- Interfacing with ActiveX Controls with JavaScript 575
What Are Web Browser Objects?
In Chapter 19, The Web Browser Object Model, you learned about the Web Browser Object Model, which dictates how your JavaScripts can access and manipulate aspects of the Web browser and the HTML document that it is viewing. The Web browser, whether Netscape Navigator or Microsoft Internet Explorer, exposes a collection of objectsthese objects control just how much you can do with your scripts. (As you will see in a few chapters, both Microsoft and Netscape extend their respective object models with their varieties of Dynamic HTML, which greatly extends the number of aspects of an HTML document that can be accessed and changed using JavaScript.)
- See Putting the Dynamic in Dynamic HTML with JavaScript, p. 621.
- See Internet Explorer Document Object Model, p. 638.
In addition to the objects exposed that are part of the Web browser (such as the window object) or part of the current HTML document itself (such as the document or image object), a number of other Web browser objects can occur within a Web page. These are objects included in the HTML document via the <APPLET>, <EMBED>, or <OBJECT> tags.
In general, the following types of content can be included in your Web pages by using one of these three tags. In many cases, although not all, the addition of this content provides additional objects that you can access and change with JavaScript.
- Java applets. Java applets are normally included in a Web page using the <APPLET> tag, although Internet Explorer 4 also supports the use of the <OBJECT> tag to include them. Both Netscape and Microsoft have provided ways to access Java objects, properties, and methods through JavaScript, and vice versa, as long as the Java applet is set up to do so. Netscape does this by using their LiveConnect technology, discussed later in the Netscapes LiveConnect section. Microsoft provides the same functionality through its own ActiveX technology and Java Virtual Machine.
- Plug-in content. Normally, content that is in a form that is not natively supported by the Web browser is included in an HTML document by using the <EMBED> tag. At the client browser, when this tag is encountered, the appropriate plug-in and/or ActiveX Control is loaded. As with Java applets, if the plug-in is set up to do so, it can expose its properties and methods that can be accessed through JavaScript. Later in this chapter, you will see examples of how this is done with the Envoy Viewer from Tumbleweed Software and with Macromedias Shockwave Flash Viewer.
Again, both Netscape and Microsoft provide this same functionality but use different methods. Netscapes LiveConnect technology enables JavaScript to access plug-in properties and methods through Java; Microsoft, which supports many of Netscape Navigators plug-ins, enables scripts to interface with the plug-ins directly.
- ActiveX Controls. ActiveX controls are a technology developed by Microsoft; Microsofts Internet Explorer is the only Web browser that fully supports them, although Netscape Navigator also supports them through Ncompass Labs ScriptActive plug-in (http://www.ncompasslabs.com). As you will see in the Interfacing with ActiveX Controls with JavaScript section later in this chapter, it is very easy to use scripts to control ActiveX controls.
- VRML. The VRML 2.0 standard also supports scripting in generaland JavaScript in particularthrough the use of its Script node. The way you include JavaScripts with a VRML source file is a lot different than in HTML and is beyond the scope of this chapter. To find more information, see the VRML Repository Web site at http://www.sdsc.edu/vrml/.
Referencing Web Browser Objects
After the objects have been included in your HTML documents, you need only to know how to reference them to access them from your JavaScripts. Objects supplied by Java applets, plug-in content, and ActiveX controls fit into the same Web browser object hierarchy discussed in Chapter 19. To use them, you must know where they fit.
- See Web Browser Object Hierarchy and Scoping, p. 462.
You can access these Web browser objects in many ways, depending on how they are included in your HTML documents. Objects exposed through the <APPLET> tag can be accessed through the applet object. Plug-ins called by the <EMBED> tag can be accessed through either the embed or the plugin object. Both these types of objects are included in the Web Browser Object Model hierarchy under the document object. Objects that are included through the use of the <OBJECT> tag are directly accessible by name through the window object, and because of the scoping rules of JavaScript, if you are controlling an object in the current window, the opening window. can be omitted.
- See The window Object, p. 463.
Java Applets Using the <APPLET> Tag
As mentioned earlier, Java applets placed in your HTML documents via the <APPLET> tag can be referenced by using the applet object. Depending on how you include the <APPLET>, however, the object can be referenced a number of ways. Consider Listing 23.1, which shows a simple Web page with a controllable Java applet.
|