JavaScript » Objects » Applet

An Applet object, created for every instance of the HTML <APPLET> tag in your document, allows the inclusion of a Java applet in a web page. These objects are then stored in an array in the document.applets property.

To enable an applet to access Javascript on your page, you must specify the <APPLET> tag's MAYSCRIPT attribute; failure to do this will cause an exception if the applet tries to access JavaScript. This allows a measure of security for each HTML page that contains the applet.

Examples

Code:
<APPLET CODE="myApp.class" WIDTH=150 HEIGHT=80 NAME="myApp" MAYSCRIPT>
Explanation:

This HTML code executes the myApp applet and sets the MAYSCRIPT attribute to allow it access to JavaScript. This will also automatically create an Applet object called "myApp" which will be added to the document.applets array and can be referenced as document.applets[0] (providing this is the first instance of the <APPLET> tag in your document) or document.applets["myApp"].

Properties

constructor

Syntax: Object.constructor

This specifies a function to create an object's property and is inherited by all objects from their prototype.

prototype

Syntax: Object.prototype.name = value

This allows the addition of properties and methods to any object.

Methods

eval

Syntax: Object.eval(string)

The eval method is deprecated as a method of Object, but is still used as a high level function. It evaluates a string of JavaScript in the context of an object.

toSource

Syntax: Object.toSource()

The toSource method returns a literal representing the source code of an object. This can then be used to create a new object.

toString

Syntax: Object.toString()

The toString method returns a string representing a specified object.

unwatch

Syntax: Object.unwatch(property)

This method removes a watchpoint set for an object and property name with the watch method.

valueOf

Syntax: Object.valueOf()

This method returns a primitive value for a specified object.

watch

Syntax: Object.watch(property, handlerfunction)

This method adds a watchpoint to a property of the object.

See Also: