简体   繁体   English

Java applet冻结浏览器以及javascript和applet之间进行通信的方式

[英]java applet freezes browser and way to communicate between javascript and applet

I have applets in my projects. 我的项目中有小程序。 When I want to display applet I load that applet using the applet tag in jsp page and load that page in div tag. 当我想显示applet时,我在jsp页面中使用applet标签加载了applet,并在div标签中加载了该页面。 it work fine. 它工作正常。 but when more applets loaded in same browser window then this window is slow down and sometime freezes and applets also becomes unresponsive . 但是当在同一浏览器窗口中加载了更多的applet时,该窗口速度变慢,有时冻结,applet也变得无响应。 when i close the applet the loading div tag still in webpage. 当我关闭小程序时,仍在网页中加载div标签。

is there any way to communicate betwwen applet and javascript. 有没有办法在applet和javascript之间进行交流。 so that when applet close we are able to remove particular div or set to empty in which applet loaded. 这样,当applet关闭时,我们可以删除特定的div或将其中加载了applet的值设置为空。

When more applets loaded I check with top command java uses more memory and cpu also. 当加载了更多的applet时,我将使用top命令检查java是否使用了更多的内存,同时使用了cpu。

is there any way to minimise it or communicate between applet and javascript. 有什么方法可以将其最小化或在applet和javascript之间进行通信。

Thanks 谢谢

To communicate with applets, all you need to do is mark methods as as public and call them like so: 要与小程序通信,您需要做的就是将方法标记为public方法,并按如下方式调用它们:

<applet code="com.something.MyApplet"
mayscript="true" name="myApplet" width="200" height="100">

Assuming a doSomething method, call it like so from your web page: 假设使用doSomething方法,请从您的网页中这样调用它:

myApplet.doSomething("Hello");

As far as the web-page crashing, that's harder to debug, try different embedding methods in different browsers. 至于网页崩溃(更难调试),请在不同的浏览器中尝试不同的嵌入方法。 Try to avoid serving more than one or two applets. 尽量避免提供一个或两个以上的小程序。 Try to figure out if an applet in particular is causing a proble. 试着弄清一个小程序是否引起了问题。

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

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