Kill Java Applet via Javascript

前端 未结 2 711

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 act

相关标签:
2条回答
  • 2021-01-23 06:10

    I would suggest that you create a class that monitors the applet to be killed. run the monitor as some sort of servlet and get javascript to post 'kill applet' commands when it needs to be killed.

    0 讨论(0)
  • 2021-01-23 06:17

    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.

    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; 
            }
        });
    }
    

    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.

    0 讨论(0)
提交回复
热议问题