please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 14
Documents and Their Contents
Next
 

14.4 The JavaObject Object

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.

Example 14.5: Invoking Methods of a Java Applet from JavaScript

<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.


Previous Home Next
The Anchor Object Book Index Saving State with Cookies

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/JAVA/SCRIPT/definitive/ch14_04.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/12/23 11:13,
TOP NEW HELP FIND: 
18.188.0.20: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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.ecomorder.com/techref/language/JAVA/SCRIPT/definitive/ch14_04.htm"> [Chapter 14] 14.4 The JavaObject Object</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to massmind.ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .