Search code examples
jqueryapplet

Hiding a java applet with jquery? Possible?


I'm struggling to find a way to hide a java applet () using jquery.

I have a link that opens up a simple ajax fancybox (http://fancybox.net) problem is that it always appears 'behind' the actual java applet.

Is there a way to 'hide' the applet or even unload it? I can reload it after closing the fancybox (basically asking for user confirmation).


Solution

  • You can remove it's DOM object, or set it's CSS property to hidden.

    jQuery("#applet").remove();
    

    or

    jQuery("#applet").hide();
    

    You can also kill the applet:

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

    However, this stops the applet, and throws JS errors in IE6

    You can also set the applets size to (1,1), and set it back when you're finished.

    jQuery("#applet").height(1).width(1);