无法从Javascript调用Java小程序方法
我试图在浏览器中加载一个小程序,并从JavaScript调用它的方法。小程序的调用如下所示:无法从Javascript调用Java小程序方法,java,javascript,applet,Java,Javascript,Applet,我试图在浏览器中加载一个小程序,并从JavaScript调用它的方法。小程序的调用如下所示: var attributes = { id: 'applet1', name: 'applet1', code: 'com.applet.MyApplet.class', archive: '../applet.jar', width: 0, height: 0, mayscript: 'yes', scriptable: 'true',
var attributes = {
id: 'applet1',
name: 'applet1',
code: 'com.applet.MyApplet.class',
archive: '../applet.jar',
width: 0, height: 0,
mayscript: 'yes',
scriptable: 'true',
separate_jvm: 'true'};
var parameters = {tokenType: "'" + jQuery("#tokenType").text() + "'"};
var version = '1.6';
var appletTag = deployJava.getAppletTag(attributes, parameters, version);
jQuery('body').append(appletTag);
当我在控制台中使用document.applet1引用上述内容时,我可以看到标记
但是,当我尝试调用我在MyApplet类中公开的简单公共方法时,我得到了以下结果:
TypeError: "document.applet1.isActive()" is not a function
init方法似乎也从未被调用过。我看到所有的安全提示,但请继续并允许加载小程序。
我正在使用Firefox35.0.1和JavaApplet插件版本7更新45
编辑:
以下是首次尝试访问小程序的JS代码:
function issueNewToken(wrongPasswordMessage) {
console.log('issueNewToken() called at ' + new Date().getTime());
try {
if (!document.applet1.isActive()) { // ERROR OCCURS HERE!
setTimeout(function () {
issueNewToken(wrongPasswordMessage);
}, 1000);
console.log('applet not ready yet. call rescheduled at ' + new Date().getTime());
return;
}
// the applet is not ready to call yet
} catch (err) {
console.error(err);
if (err instanceof TypeError) {
setTimeout(function () {
issueNewToken(wrongPasswordMessage);
}, 1000);
console.log('applet not ready yet (exception caught). call rescheduled at ' + new Date().getTime());
return;
}
// all other errors such as user do not allow applet to run
else {
hideModalCover();
alert(err.message);
return;
}
}
/// We have access to applet.. more work done here...
}
任何建议都将不胜感激。我建议您启用Java控制台并检查Windows上的日志:控制面板=>Java=>Advanced选项卡=>Java控制台选项=>Show Console。同时发布您为调用applet方法编写的代码,这可能会有所帮助。@ivan.aguirre是的,我打开了控制台,但它没有记录任何感兴趣的内容。我将用调用小程序的代码更新问题。检查小程序清单。请看一下.@ivan.aguirre参数设置如下:调用方允许的代码库:*