java applet 可以操作包含它的 HTML 页面吗? [英] Can a java applet manipulate the HTML page containing it?

查看:27
本文介绍了java applet 可以操作包含它的 HTML 页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在包含 Java 小程序的 HTML 页面上从小程序中编写一些内容.

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?

谢谢.

推荐答案

从你的 Java 小程序中

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");

然后您可以像往常一样使用 javascript 操作 html 页面.

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

在声明小程序时可能还需要包含 mayscript 参数,不确定是否不再需要.

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

这篇关于java applet 可以操作包含它的 HTML 页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆