Java小程序可以操纵包含它的HTML页面? [英] Can a java applet manipulate the HTML page containing it?

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

问题描述

我想知道如果我能写HTML网页上的东西从applet中包含我的Java小程序。

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 applet中

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小程序可以操纵包含它的HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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