The JavaObject object is a JavaScript object that serves as a wrapper around Java objects. It allows JavaScript programs to read and write the public fields of a Java object, and also to invoke the public methods of a Java object. Chapter 19, LiveConnect: JavaScript and Java, covers the "LiveConnect" mechanism for communication between Java and JavaScript, and will explain JavaObjects in detail, as well as the JavaArray, JavaClass, and JavaPackage objects.
The reason that JavaObjects are being discussed here is that in Navigator 3.0, the applets[] and embeds[] properties of the Document object are arrays that contain JavaObjects. Elements of the applets[] array are created when a Java applet is included in the document with the <APPLET> tag. Each JavaObject in this array represents the Java Applet object. Similarly, elements of the embeds[] array are created when embedded data are included in the document with the <EMBED> tag. In Navigator, the <EMBED> tag specifies data to be displayed through a plug-in, and the JavaObject objects in the embeds[] array are Java objects provided by the plug-in that allow it to be controlled through a Java-based interface. If a plug-in does not support Java--and many plug-ins currently do not--then the entry in the embeds[] array will be a dummy object with no functionality.
Both the <APPLET> and the <EMBED> tags have optional NAME attributes. If you specify a name for either of these tags, then a property with that specified name will be created in the Document object. The value of this property will be a reference to the JavaObject for the applet or embedded data. Using the NAME attribute in HTML can make your JavaScript code more readable--you can use expressions like document.myapp instead of document.applets[0].
Example 14.5 shows how you might embed a Java applet in a web page with the <APPLET> tag, and then invoke the start() and stop() methods of that applet from JavaScript event handlers.
<APPLET NAME="animation" CODE="Animation.class" WIDTH=500 HEIGHT=200> </APPLET> <FORM> <INPUT TYPE=button VALUE="Start" onclick="document.animation.start()"> <INPUT TYPE=button VALUE="Stop" onclick="document.animation.stop()"> </FORM>
The topic of interacting with Java from JavaScript is a broad one, and deserves a chapter on its own. We'll learn more about the JavaObject object and the applets[] and embeds[] arrays in Chapter 19, LiveConnect: JavaScript and Java.
file: /Techref/language/java/script/definitive/ch14_04.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/21 14:05,
3.142.212.119:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/techref/language/java/script/definitive/ch14_04.htm"> [Chapter 14] 14.4 The JavaObject Object</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.