Can a java applet manipulate the HTML page containing it?

≯℡__Kan透↙ 提交于 2019-11-29 12:17:51

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.

You could use the JSObject.

Sun: java to javascript communication

A java applet can call javascript functions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!