小程序间通信 [英] Inter applet communication
问题描述
在我的理解中,每个小程序都是独立的实体.有没有可能小程序间通信 ?.如果是这样,如何实现?
In my understanding each applets are independent entities . Is it possible to have inter applet communication ? . If so , how it could be achieved ?
谢谢J
推荐答案
是的.如果它们在同一页面上并且来自同一域,则可以实现小程序间通信.您必须首先使用属性name=value"命名页面中的小程序,例如:
Yes. It is possible to achieve inter-applet communication if they are on the same page and originating from the same domain. You will have to name the applets in the page first using the attribute "name=value" like:
<applet code="FirstApplet.class" name="firstApplet" width=nn height=nn></applet>
<applet code="SecondApplet.class" name="secondApplet" width=nn height=nn></applet>
在上面的地方,在 FirstApplet.java 中,使用以下内容访问 SecondApplet:
with above in place, in FirstApplet.java, use the following to access SecondApplet:
SecondApplet secondApplet =
(SecondApplet)getAppletContext().getApplet("secondApplet");
//invoke a method on secondApplet here
同理,可以在SecondApplet.java中访问FirstApplet
Similarly, you can access the FirstApplet in SecondApplet.java
这篇关于小程序间通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!