从Java小程序调用Javascript函数 [英] Calling Javascript functions from a Java Applet

查看:155
本文介绍了从Java小程序调用Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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中的实际功能,但在实际的小程序调用它,我得到
未捕获的Ref​​erenceError: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屋!

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