Results 1 to 4 of 4

Thread: clsoe browser

  1. #1
    Join Date
    Dec 2002
    Posts
    20

    Red face Unanswered: clsoe browser

    Dear All

    Does anyone one know how to clsoe IE?

    I'm using the onbeforeunload event which works fine but i don't want a dialog box to show, also I don't want the code to run when the backbutton is pressed, i only want the code to run when the (X) in the top right of the browser is clicked

    This is what i'm using so far, a basic example
    <SCRIPT>
    function closeIt()
    {
    event.returnValue = "Are you sure you want to close the browser";
    //event.returnValue = false;
    }
    </SCRIPT>
    </HEAD>
    <BODY onbeforeunload="closeIt()">
    </BODY>
    </HTML>

    any help?

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721

    Re: clsoe browser

    It's not ASP code, but JavaScript.

    window.close();

    But here's the problem, if you're closing a browser window the user opened, they will get a popup saying "This webpage is attempting to close your browser, do you want to?" (or along those lines) - this is a security feature. Now, if you create the window in JavaScript, you can close it without getting a popup box.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    May 2003
    Posts
    23
    If you do not want the security prompt, do the following:

    window.opener = null;
    window.close();

    Is this a flaw? I aint sure.
    Last edited by fused; 09-14-03 at 01:12.

  4. #4
    Join Date
    Sep 2003
    Posts
    6

    Thumbs up

    That's magic! Great! My answer was the same as seppuku's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •