How do I communicate with JavaScript from an applet?

Andre van Dalen

Communication between an applet and Javascript is achieved via the netscape.javascript.JSObject class. The netscape.javascript package is also part of Internet Explorer, so don't be intimidated by the fact that it's a Netscape package. The browser allows the applet to use this class when MAYSCRIPT is included in your applet tag.

The following code pieces illustrate its use:

import netscape.javascript.*;

    private JSObject javaScript = null;
    javaScript = JSObject.getWindow(this);

    if (null != javaScript)
    {
        Object[] args = new Object[1];
        args[0] = arg;

         javaScript.call("myFunc", args);
     }

The netscape.javascript package is included in the java40.jar in the netscape navigator installation as well as jaws.jar which ships with the standard JRE1.3+.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact