通过Javascript杀死Java Applet [英] Kill Java Applet via Javascript

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

问题描述

我正在为一家正在发展的公司工作,并且正在对Web应用程序进行重大的重新设计,该应用程序在每次点击后重新加载所有内容,以广泛使用Javascript,因此它实际上感觉就像一个真正的Web应用程序。其中一个功能是使用基于Web的Painter(在Web上考虑MSPaint),我将其嵌入到按需页面中。绘制并上传图像后,Web应用程序然后卸载applet并继续显示文件上传到的目录。

I am working for a developing firm and am doing a major redesign on a Web Application, which reloaded everything after each click, to make extensive use of Javascript, so it actually feels like a real Web application. One of the Features is to use a web-based Painter (think of MSPaint on the Web), which I embed on the Page on Demand. After the image is painted and uploaded, the Web-app then unloads the applet and proceeds to show the directory where the file was uploaded to.

这是Trouble启动的地方。这一切都适用于IE和Safari,但不适用于Firefox 3.5(虽然3.0可以很好地工作)。 Firebug告诉我,expando属性丢失。

This is where Trouble starts. It all works on IE and Safari, but not on Firefox 3.5 (3.0 works perfectly though). Firebug tells me that the expando property is missing.

之前我正在研究的Web应用程序Tiparlo有一个类似的问题(实际上,对applet进行的任何操作)通过jQuery是错误的)但通过包裹div并控制(隐藏和显示)div而不是applet解决了这个问题。遗憾的是,这不适用于此Web应用程序,因为Applet必须被销毁,而不仅仅是隐藏和显示,因为它占用了太多资源,无法在不需要的时间内运行。

The Web-app Tiparlo which I was working on before had a similar Problem (in fact, any manipulation done on an applet via jQuery is faulty) but solved that Problem by wrapping a div around and controlling (hide and show) the div instead of the applet. This, unfortunately isn't applicable on this Web-app, because the Applet has to be destroyed and not just hidden and shown, as it takes up too much resources to be run the entire time where it is not needed.

为了简化:是否可以通过Javascript使Applet自行销毁?或者:是否有关于jQuery / expando / applet问题的解决方法?我知道applet在HTML 4.01严格中已被弃用,但现在不能将它更改为object。

To make it short: Is it possible to make an Applet destroy itself via Javascript? Alternatively: Is there a workaround on the jQuery/expando/applet problem? I know that applet is deprecated in HTML 4.01 strict but changing it to object is not an option right now.

编辑:我添加了Firefox + Firebug的图片以显示你真正的错误信息。发布代码没有上帝,因为它在所有其他浏览器上运行完美,并且是Firefox 3.5特定的问题。 这里是照片

I have added a Picture of Firefox + Firebug to show you the actual Error Message. Posting Code does no god, since it works flawless on every other Browser and is a Firefox 3.5 specific Problem. Here be pictures

注意:您可以忽略来自button.js的JS Bug。

Note: You can ignore the JS Bug coming from button.js.

推荐答案

您可以随时加载iframe中的applet,只是从加载applet的页面导航。这将杀死它。

You could always load the applet in a an iframe and just navigate away from the page where the applet is loaded. This will kill it.

如果你想从javascript调用destroy,你的另一个选择就是把这样的东西放进去。

Your other option if you want to call the destroy from javascript would be to put something like this in.

<script>
    document.MyApplet.killApplet();
</script>

public void killApplet() {
    AccessController.doPrivileged(new PrivilegedAction() {
        public Void run() {
            // kill the JVM System.exit(0); return null; 
        }
    });
}

这不是杀死小程序的好方法,但在较新的浏览器上它确实如此不抛出JS错误,对于像IE6这样的旧版本,它会抛出一个js错误。

This is not a nice way to kill an applet but on newer browsers it does not throw a JS error, on older ones like IE6 it will throw a js error.

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

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