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

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

问题描述

我在 HTML 页面中有一个 Java Applet.我需要让小程序调用某个 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 代码中定义了实际功能,但是当小程序实际调用它时,我得到Uncaught ReferenceError: notifyEvent is not defined 错误.

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.

我需要在哪里定义小程序的 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.

BridgeJava小程序和网页上的文本输入控件之间

这篇关于从 Java Applet 调用 Javascript 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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