从Java小程序调用Javascript函数 [英] Calling Javascript functions from a Java Applet
问题描述
我有一个Java小程序的HTML页面。
我需要有小程序调用某个JavaScript函数来通知某些事件的HTML页面。
I have a Java Applet in a HTML page. I need to have the applet call a certain Javascript function to notify the HTML page of certain events.
我调用JavaScript函数的方式是目前:
The way I call the JavaScript function currently is:
getAppletContext().showDocument(new URL("javascript:window.notifyEvent("+msisdn+")"));
我定义HTML code中的实际功能,但在实际的小程序调用它,我得到
在未捕获的ReferenceError:notifyEvent没有定义
错误
我在哪里需要定义JavaScript函数的小程序能打电话吗?
Where do I need to define the javascript function for the applet to be able to call it?
谢谢!
推荐答案
要做到这一点,你必须使用的 JSObject 。它已经存在很长一段时间,虽然我听说可以有浏览器仍然之间的差异。所以,如果你需要支持许多浏览器我建议在您的支持组检查,一旦你看到它在工作之一。
To do this, you must use 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.
<一个href=\"http://stackoverflow.com/questions/6014561/bridge-between-the-java-applet-and-the-text-input-controls-on-the-web-page\">Bridge Java程序和网页文本输入控件之间
这篇关于从Java小程序调用Javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!