views:

243

answers:

4

I have a large applet that takes some 40 seconds to initialize (cabs are cached so ignore download time for this question).

The issue is, if the user goes to Page A which launches the applet (single window) and then navigates to page B, the applet is unloaded. If the user goes back to Page A, they incur the 40 seconds init time once again.

I'd like to be able to launch the applet, incurring the 40 seconds init time once and only once. The applet needs to reside inside a single browser window (the same window as my web application). In other words, I cannot launch the applet in a popup.

Does anyone have any creative ideas around how to prevent the applet unloading?

A: 

Put the Applet in a frame that doesn't unload, or prevent the user from going to another page in the web page that contains the Applet.

Eddie
A: 

The only option would be to put you content in an iframe that encompasses your whole document and use absolute positionning for the applet.

<body>
 <iframe id='content' src='FIRST_URL'></iframe>
 <object id='applet'></object>
</body>

With a css like this one:

#content {
  width:100%;
  height: 100%;
}

#applet {
  position: absolute;
  left: LEFT_POSITION;
  top: TOP_POSITION;
  width: DESIRED_WIDTH;
  height: DESIRED_HEIGHT;
}

There are MANY drawbacks:

  • The applet will always be positionned at the same place, no matter the page
  • You will suffer to get the iframe full width and full height, especially in IE
  • It's possible you will also suffer to have the applet showing properly (an object on top of an iframe, I can't imagine what troubles you'll run into)
  • The applet will stay if your user click to a link leading outside of your site unless you set a target for the link (ie, target='top' or target='__blank')
Julian Aubourg
If I did this, the browser URL would never change from page to page. Not really what I'm looking for.
A: 

I thought maybe there'd be a way to popup a tiny browser window and have the applet load in that, then using Javascript somehow pull in the applet from the smaller window into the larger browser.

I don't think I can manipulate the DOM in this way though.

Any other ideas?

A: 

You could show a warning, this way:

if(window.body)window.body.onbeforeunload=function(){if(window.event)window.event.returnValue="UNLOAD MSG";};else window.onbeforeunload=function(){return "UNLOAD MSG";};

This works in allmost every browser, but you cannot change the text surrounding your text.

springfeld