views:

222

answers:

2

Hiding a Java applet using display: none causes firefox to kill the applet until it is visible again. It also seems to kill the applet if you position the applet out of view ie. position: absolute; left: -9999; Using visibility: hidden; will hide the applet without killing it, but then the applet still takes up space in the layout which doesn't work for my application. Does anyone know of a workaround to prevent firefox from killing java applets when they're hidden via display or a negative position offset??

The usage is a java upload applet that I'd like to hide during an upload without killing the upload.

+2  A: 

The issue isn't isolated to just Java applets. Flash and other plugins have the same issue. They do this save on resources and for backward compatibility.

I have cheated by changing visibility to hidden and setting the position to absolute and then putting it in a negative z order and other nasty tricks.

Zac Bowling
ya I know it happens for all plugins. My particular problem was with an applet, so I structured my question to be a little more specific. Perhaps I'll try a combination of hidden and positioning as you mention.
wallacer
+2  A: 

The behaviour of applets while hidden is entirely browser-specific. Safari 4, for example, calls stop() when the user changes to a different tab and then start() when changing back to the applet tab (at least on mac it does, not sure about windows).

Rather than use position hacks, set the applet to a 1x1 pixel size. That leaves a white dot on the screen but is the only really cross-browser way to guarantee the applet stays active.

Spyder
+1 good idea, and you can always change it's colour if needed.
Pool
Yours is the best answer for most situations. Not gonna work for me, but thanks!
wallacer