views:

767

answers:

2

Hi there,

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.

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.

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.

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.

EDIT: 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

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

A: 

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.

Charles Ma
+1  A: 

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.

Knife-Action-Jesus
Yep, this one solves the problem (generates a new one but I can handle that one).
Mike
What was the new problem it created, just curious.
Knife-Action-Jesus