Rohan Khanna
Rohan Khanna

Reputation:

How can I open and close a browser window from a Java applet?

I would like to open a new window at Google.com, but then later close that window. My current code is as follows:

link="http://www.google.com"

try
{
    AppletContext a = getAppletContext();
    URL url = new URL(link);
    a.showDocument(url,"_blank");
}
catch (MalformedURLException e)
{
    System.out.println( e.getMessage() );
}

This opens the window, but how do I close it later?

Upvotes: 0

Views: 2014

Answers (1)

jsight
jsight

Reputation: 28409

I'd suggest using the JSObject interface to call into the browser for opening the windows. Then you can get the variable of the new window and use that to close it.

More documentation:

Upvotes: 1

Related Questions