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


1 import java.applet.*; import java.awt.*;
2 import netscape.javascript.JSObject;
3 public class SayThanks extends Applet {
4 JSObject win;
5 String str = "Click for an important message";
6 int x = 25; int y = 25;
7 public void paint ( Graphics g ) {
8 g.drawString ( str, x, y );}
9 public void init()
10 { win = JSObject.getWindow(this);}
11 public boolean mouseUp(Event e, int x, int y)
12 { JSObject document =
13 (JSObject) win.getMember ( "document" );
14 Object args[] = new Object[1];
15 String title =
16 (String) document.getMember ( "title" );
17 args[0] = "Thanks for visiting " + title;
18 win.call ( "alert", args );
19 return true;
20 }

in Table To:


© 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