简体   繁体   English

小程序自动关闭

[英]Applet closes automatically

I have a very simple java applet which reads the audio files data from user directory. 我有一个非常简单的Java小程序,它从用户目录中读取音频文件数据。

I am using applet function in javascript. 我在javascript中使用小程序功能。 The problem is my applet closes after 15 seconds automatically and hence the function is not called. 问题是我的applet在15秒后自动关闭,因此未调用该函数。

I have signed the applet. 我已经签署了小程序。 Certificate is also generated but applet (more precise file chooser ) closes after 15 seconds. 还生成了证书,但是applet(更精确的文件选择器)在15秒后关闭。

Any help? 有什么帮助吗?

..I am using applet function in javascript ..我在javascript中使用小程序功能

When mixing JS and trusted code, it is necessary to wrap that code in a AccessController.doPrivileged(PrivilegedAction) method. 在混合JS和受信任的代码时,有必要将该代码包装在AccessController.doPrivileged(PrivilegedAction)方法中。 Since appletviewer does not support JS, that suggests why AV can open it, whereas a browser might not be able to. 由于appletviewer不支持JS,这说明了为什么AV可以打开它,而浏览器却不能。

Alright people, I found the solution. 好的,我找到了解决方案。 :) :)

The problem occurs when we use java applet function in javascript. 当我们在javascript中使用java applet函数时,会发生问题。 Javascript runs after 15 seconds of page load and this time is left for applet I suppose. Javascript在页面加载15秒后运行,我想这是Applet剩下的时间。 When we call the function of applet, it comes up with an error. 当我们调用applet函数时,它会出现一个错误。

So, I changed the algorithm to achieve my requirements. 因此,我更改了算法以实现自己的要求。 Now I have put all the javascript in one function and I call it from applet. 现在,我将所有的javascript放在一个函数中,并从applet中调用它。 simple! 简单!

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

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