Closing a browser window from applet

i have applet opened in a IE browser.
The applet contains TOOL BAR and one of the buttons in it is EXIT.so when i click this exit button the browser window should close.
if any one has idea about it please let me know along with sample code.
thanx in advance.

try this
on click of that exit button in action event write this
System.exit(0);

Similar Messages

  • Getting hang/crash problem when I try to close browser window from applet

    I have a small Apllet that has a button that calls a Javascript function in the opening window, to close the window in which it is loaded.
    The Applet window is a PopUp window from one of my application's window. First time I start my application and load that Applet the button works fine. It calls the Javascript method and the Method closes the window using the self.close() method.
    But now if I open the applet window again and click on the button to close the windows, it hangs. I put in trace statements and saw that it hangs on JSObject.getWindow() window.
    I am using JDK Plugin 1.4.2_07 and 5.0 , if I work out on IE browser, it works fine.But when I use firefox or mozilla it gives problem of hanging/crashing.
    Note that in case of 1.4.2_07 this problem experienced some times but in case of 5.0 it gives always for other than IE browser.
    Please, if somebody could give me some clue about why this would happen, I will really appreciate that. and code related to this is given below
    import javax.swing.JApplet;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import netscape.javascript.JSObject;
    public class TestApplet extends JApplet implements ActionListener{
    protected JButton closeButton = null;
    protected JSObject win = null;
    private JFrame frame = null;
    private boolean alreadyClosed = false;
    public void init(){
    this.win = JSObject.getWindow(this);
    this.closeButton = new JButton("Close Browser Window");
    this.add(this.closeButton);
    this.closeButton.addActionListener(this);
    frame = new JFrame("Test Frame");
    frame.setSize(300, 400);
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.out.println("windowClosing");
    alreadyClosed = true;
    TestApplet.this.stop();
    frame.show();
    public void actionPerformed(ActionEvent ae){
    stop();
    public void stop() {
    if (!alreadyClosed) {
    alreadyClosed = true;
    frame.dispose();
    closeLaunchedBrowser();
    System.gc();
    System.runFinalization();
    private void closeLaunchedBrowser() {
    final TestApplet thisObject = this;
    Runnable r = new Runnable() {
    public void run() {
    try {
    JSObject win = (JSObject)JSObject.getWindow(thisObject);
    if (win != null && win.toString() != null) {
    //win.eval("top.opener=self;self.close();");
    //win.call("close", null);
    win.eval("self.close();");
    } catch (Exception e) {
    Thread t = new Thread(r);
    t.start();
    Thanks.

    I am waiting for any reply. I have tried for all these below options still I am getting Problem. I heard this is because of javascript, it wont call methods more times .Thats
    why I need other than JSObject or java script solution.If some one know anything about this or any modifications I have to made for the below options to avoid that problem please let me know.
    // URL durl = new URL(thisObject.getCodeBase(), "test/CloseMe.htm");
    // System.out.println("URL :" + durl.toString());      
    // thisObject.getAppletContext().showDocument(durl);
    //     thisObject.getAppletContext().showDocument(new URL("javascript:window.close();"), "_self");
    //win.eval("top.opener=self;top.close();");
    //win.call("close", null);
    //Object[] args = { "close", new Integer(50) };
    // win.call("setTimeout", args);
    //win.eval("setTimeout("close", new Integer(50));");
    If it is the problem of JRE I just need it should work on 1.4.2_01 or higher.
    thanks.

  • Close browser window from applet

    I have a simple applet that is called
    from another application through HTML.
    When the applet is done, I'd like to have
    it exit and close its browser window.
    How is this done? I tried System.exit(),
    and that didn't do it. Neither did
    destroy().

    The only thing I can think of is to have a function defined in JavaScript on your html page and have the applet call the method. For you to be able to do this you will have to have a MAYSCRIPT set in your applet tag.
    IE:
    <script language="JavaScript">
    function closeWindow()
    window.close();
    </script>
    <APPLET code="XYZApp.class" codebase="html/" align="baseline" width="200" height="200"
    MAYSCRIPT>
    </APPLET>
    In your applet:
    Make sure that you import the following.
    import netscape.javascript.*;
    JSObject win = JSObject.getWindow( this );
    win.call( "closeWindow", null );// Calls the closeWindow() on the HTML page.

  • Opening browser windows from applet

    I have 2 questions
    1) Does anyone know, what do I have to do to force my java applet to open new browser window with specified url ?
    2) Is any java class, which renders HTML files ? I'm trying to open some document in frame inside applet and I don't know if i have to write this renderer by myself.

    for your second question, I dont know if there is a specific HTML class but SAXParser makes reading xml very easy and you probably should have much trouble writing a class to read html.

  • How to close Browser window from Applet ?

    I am looking to close the browser window based on an action within applet . any ideas ?

    Hi U can close the Browser window in which the applet
    opened
    try this,
    Just call this where u want to close the browser
    import java.net.*;
    URL url;
    url=getCodeBase();
    try{                    getAppletContext().showDocument (new URL (url+"close.htm"));
    }catch(MalformedURLException e){showStatus("no file");}
    In the close.htm have this code
    ///close.htm
    <HTML><SCRIPT>
    <!--
    window.close();
    //-->
    </SCRIPT></HTML>

  • Open a new browser window from applet

    Anybody know how to open a new Netscape window by pressing a button in an applet? Which class handles it?
    Thanks a lot.
    wz

    http://forum.java.sun.com/thread.jsp?forum=54&thread=106906
    http://forum.java.sun.com/thread.jsp?forum=54&thread=272870
    http://forum.java.sun.com/thread.jsp?forum=54&thread=272829

  • Closing a browser window from servlet

    Hi
    I generate a pdf document using itext and open it in a web browser which has a button save and close, on the click of this button, a servlet is been called. Now my question is, after the execution of the servlet, I need to close the browser where the pdf was shown. How do I achieve this.
    Any help is greatly appreciated.
    Thanks

    On the server response, write something like
    <html>
    <head></head>
    <body>
    <script>window.close();</script>
    </body>
    </html>There's no way that I know of to close the browser inside the servlet as the servlet is not executed on the browser, but in the server ;-) So you may have to play with Javascript to do that.

  • Closing browser window from an Applet?

    I've written a series of applets that perform different functions. I placed a button on each applet with the purpose to close the window in which that applet is running. However I don't even know where to start looking to find out how to make my applet close it's own browser window. I know how to open a new browser window from an applet but not vice versa.
    Can anyone help please?
    Mark.

    Right, I sort of tracked down some code that uses getMethods to allow me to invoke a Javascript command. It is not pretty and took a little bit of editing to get to work but it does the job without putting JS stuff into my HTML.
    However it is causing some problems. If I open one of my other applets it will only let me close that window and the previous applets ceases to respond at all. I think this may be because the invoke gets the JSObject which is the window and somehow having more than one applet open in different windows is causing it to get confused and is locking the first window and only responding to the second.
    I have seen a much simpler method that uses:
    import netscape.javascript.*;
    and JSObject to get the window but my compiler complains about the import. Any further suggestions or an example would be welcome as my current solution is a bit limited as you can effectively only have one window open at a time which doesn't suit my needs.
    Many thanks.
    Mark.

  • Closing browser window from Flash movie on CD

    I have to put a flash lesson I created on a cd for a client and while testing it I noticed that my exit button in the movie no longer seems to function.
    This is my close window function
        function closeWindow(evt:Event)
            var url:String = "javascript:window.opener=self; window.close()";
            var request:URLRequest = new URLRequest(url);
            try
                navigateToURL(request, "_self");
            catch (e:Error)
                trace("Error occurred!");
    Can anyone tell me why this wouldn't work when the movie is launched in a browser window from a CD?

    Fi it is at all possible you cannot do that with url request.
    Try using ExtrenalInterface class:
    ExternalInterface.call("javascript:...");
    It may not waork though depending on security settings and embed parameters.

  • How do I open a new browser window from Flash

    I wish to open a new browser window from Flash and when the new window closes to return to the location from whence I started.
    ThomasChen

    The command to open a new window would be the "_blank" part of a command to link to a web page in the code below.
    navigateToURL(new URLRequest("http://www.anothersite.com", "_blank"));
    As far as the new window closing and getting back to where you were in the original window, I don't understand where that original window might have gone to... You should be wherever you last left it.

  • Open new browser window from a JApplet

    Hi,
    I want to open a new browser window from a JApplet.My first thought was to use the Live Connect technology but it worked only with simple applets not with JApplets.Then i tried it by getting the Applet context (getAppletContext() method) but it still didn't work with JApplet...(it worked with Applet).I believe it has something to do with the applet security but i haven't yet figured it out.
    For example when i call the getAppletContext() method from a JApplet i get an java.security.AccessControlException ... .Thanks

    I must correct myself now :).
    The getAppletContext() method does work with JApplets too.Still , i have problems with the Live connection alternative.It seems that it by importing the netscape.javascript package i get the security eror that i mention above...

  • Open a new Window from Applet --- beginner

    Hi all,
    I need to open a browser window from an applet and control the window properties (width, height .. etc). Can anyone please give a code example for this
    thank you.

    hi
    First, thank you for your reply.
    Second, I need to know how could I found this Netscape calss to can be abelto import it.
    And I want to know if it will work on (IE) browsers or it is just working on Netscape Browser.
    Thank you again :)

  • Issue Tracker app closing the browser window on chart page

    Hi!
    I am walking through the Issue tracker tutorial. I have created page 10 (Issues Resolved by Month) which is the chart page. Everything looked fine until I try to run the page. Then it simply closed the browser window after it authenticates me. Anyone else see this? Any ideas?
    Thanks!

    Probably a problem with your SVG viewer installation. Does it happen on other chart pages as well? What browser/svg viewer version combination are you using? There are some known issues with what's labeled as the current svg viewer on Adobe's website and Firefox.
    Earl

  • Open new browser window from Hyperlink in BIP PDF output report?

    Hello,
    Is there a way to open a new browser window from Hyperlink in PDF report?
    Thank you all in advance.
    MT

    Dear Friend,
    It is not supported for PDF Report. But below links helps you, to accombish this task in PDF report.
    [url http://oracleapps4u.blogspot.com/2011/03/open-hyperlink-in-new-browser-window.html]http://oracleapps4u.blogspot.com/2011/03/open-hyperlink-in-new-browser-window.html
    Thanks & Regards
    Ahamed Rafeeque Cherkala

  • New browser window from uix

    How can I open a new browser window from an event handler in UIX?
    Thanks in advance,
    Martmn Patrici

    I just tried your suggestion. Unfortunately, it did not work. Here's the UIX code I used:
    <tableSelection>
    <singleSelection model="${bindings.MPOOrdersView1Iterator}" text="Select">
    <primaryClientAction>
    <firePartialAction targets="_uixState MplistsView11" source="MPOOrdersView10" event="select"/>
    </primaryClientAction>
    <contents>
    <submitButton formName="mlrhomeform" text="Print Lists" event="print" />
    <submitButton text="View Merge Reports" event="mergerpts" formName="mlrhomeform" targetFrame="_blank"/>
    </contents>
    </singleSelection>
    </tableSelection>
    The only difference from the original code is the addition of the targetFrame="_blank" in the submitButton.
    It had no effect. My redirected page showed up in the same browser window. This left me with an expired page when I press the Back button on the browser.
    My assumption is the response.sendRedirect() call wipes out the targetFrame setting.
    Does anyone know how the browser (Internet Explorer in this case) actually gets notified to open a new window? There's got to be something that the targetFrame="_blank" sets up to cause it.
    I know that Netscape supports a "Window-target:" header, but unfortunately IE doesn't. Is there some "standard" header that I can put in a response.addHeader() call that would tell all browsers to open a new window?
    Of course, a UIX solution would be preferrable!
    Any other ideas?

Maybe you are looking for