简体   繁体   English

从Java Applet调用Javascript函数

[英]Calling Javascript functions from a Java Applet

I have a Java Applet in a HTML page. 我在HTML页面中有一个Java Applet。 I need to have the applet call a certain Javascript function to notify the HTML page of certain events. 我需要让applet调用某个Javascript函数来通知HTML页面某些事件。

The way I call the JavaScript function currently is: 我目前调用JavaScript函数的方式是:

getAppletContext().showDocument(new URL("javascript:window.notifyEvent("+msisdn+")"));

I define the actual function within the HTML code but when the applet actually calls it I get the Uncaught ReferenceError: notifyEvent is not defined error. 我在HTML代码中定义了实际的函数,但是当applet实际调用它时,我得到了Uncaught ReferenceError: notifyEvent is not defined错误。

Where do I need to define the javascript function for the applet to be able to call it? 我在哪里需要为applet定义javascript函数才能调用它?

Thanks! 谢谢!

To do this, you must use JSObject . 为此,您必须使用JSObject It's been around for a long time, although I hear there can be differences between browsers still. 它已经存在了很长时间,虽然我听说浏览器之间仍然存在差异。 So if you need to support many browsers I'd suggest checking across your supported set once you see it work in one. 因此,如果您需要支持许多浏览器,我建议您在支持的设备上查看它时,建议您检查它是否合作。

Bridge between the Java applet and the text input controls on the web page Java applet与网页上的文本输入控件之间的桥接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM