2

I wanted to know if I can write something on the HTML page containing my Java applet from within the applet.

More generally, what interactions are possible between these two?

Thanks.

Tom Hawtin - tackline
  • 145,806
  • 30
  • 211
  • 305
Mohammad Alinia
  • 320
  • 2
  • 9

3 Answers3

4

From within your java applet

 // object to allow applet to invoke Javascript methods
protected static JSObject appletWindowJSObject = null;

appletWindowJSObject = JSObject.getWindow(this);

 //Call your javascript method on the page and pass it something
 appletWindowJSObject.call("myJavascriptMethod", "This is what I am passing");

You can then use javascript to manipulate the html page as usual.

May also need to include the mayscript parameter when declaring the applet, not sure if this is needed anymore or not.

Keibosh
  • 1,237
  • 1
  • 9
  • 18
1

You could use the JSObject.

Sun: java to javascript communication

fgui
  • 1,564
  • 1
  • 13
  • 14
0

A java applet can call javascript functions.

FWH
  • 3,205
  • 1
  • 22
  • 17
  • It seems this: getAppletContext().showDocument(new URL("javascript:doSomething()")); could be the answer. Is there any other way? – Mohammad Alinia Jul 24 '09 at 08:19