Posted by Joe Weber on April 04, 1996 at 09:51:00:
In Reply to: Unable to Retain Applet Context posted by Mike Afergan on March 13, 1996 at 14:21:31:
: Here's a message that I posted to comp.lang.java. Let's see
: if this message board proves more useful.
: I am creating an applet that will spawn a child
: Frame (An "Untrusted Java Applet Window"). From this
: window, the user has the ability to load a new HTML page
: in the original page using the
: context.showDocument( URL ); command
: where context is an appletContext passed to the
: frame in the constructor method.
: While this works for the first document
: (I am able to go from my HTML page to say Netscape.),
: I am unable to access the appletcontext (browser) after
: that. (After arriving at Netscape, I can no longer display a new page or use any of the other appletContext methods such as showStatus().)
: My code does not crash and I still can play around
: with the frame. However, I cannot effect the browser's
: screen anymore.
: I have tried passing the entire applet to the frame
: and invoking the getAppletContext() to try to "refresh" the
: context variable to no avail.
: I suspect that the problem stem from the fact that
: the original applet no longer exists - It was replaced
: by the new HTML page. However, the appletcontext is still
: the same browser, so I should be able to retain control.
: What am I missing?
: -- Mike
The problem is that after you switch pages, the
applet can no longer access the current context of
the current window, since it has been changed.
There are two solutions to this: 1) have each
page have an instance of your applet so that it
properly updates the current context... but
this is probably not an option. The second is
to show the context in a new window. In other
words use: showDocument(URL,string) where the
string is the name of the new window... it will
cause Netscape to spawn a new browser.
Neither of these solutions are perfect, but they
are the best I know.
Post a Followup