1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Rep Power

    close window with applet

    If I am running an applet, after I stop it, how can I close the window it is running in?

  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Lincoln, NE. USA
    Rep Power
    Not sure what you mean when you say "after you stop it". How do you stop it?

    Anyway, the only way to do anything to the browser that I know of is to use the JSObject object. It gives you an interface to the browser using javascript. Use the eval or call methods.


    Here is an example of how to use it
    JSObject win = JSObject.getWindow(this);
    win.eval("alert(\"Hello world!\");");
    Though the getWindow method is not listed in that javadocs page, that is the way you get a JSObject object. You cannot call the JSObject constructor. The netscape.javascript package is included with the plugin if a user has it installed you can use it in your applet. However, when doing development you may need to make sure this package is in your classpath. The package is called jaws.jar and it is located in the jre/lib folder of your sdk. You do NOT have to include this jar file with your applet though when you deploy it.

    Note, trying to close a window from javascript that was not opened from a browser (by either the window.open() method or a link with a target value) will cause the window to prompt the user if they really want to close the browser.

IMN logo majestic logo threadwatch logo seochat tools logo