Basic HTML version of Foils prepared 2 October 98

Foil 9 Example Java Code Accessing JavaScript

From Netscape's LiveConnect Technology CPS640 Internet and Multimedia Technologies -- April 98. by Marek Podgorny,Nancy McCracken


import java.applet.*; import java.awt.*;
import netscape.javascript.JSObject;
public class SayThanks extends Applet {
JSObject win;
String str = "Click for an important message";
int x = 25; int y = 25;
public void paint ( Graphics g ) {
g.drawString ( str, x, y );}
public void init()
{ win = JSObject.getWindow(this);}
public boolean mouseUp(Event e, int x, int y)
{ JSObject document =
(JSObject) win.getMember ( "document" );
Object args[] = new Object[1];
String title =
(String) document.getMember ( "title" );
args[0] = "Thanks for visiting " + title;
win.call ( "alert", args );
return true;
}



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Nov 29 1998