Code to Exit Web App and Exit Internet Explorer

Discussion in 'ASP .Net' started by =?Utf-8?B?U2FuZHk=?=, Aug 3, 2005.

  1. Hello -

    I have a little application that I would like to have an exit button on that
    closes my web application and closes Internet Explorer.

    What is the code that will do that?

    Any help will be greatly appreciated!

    --
    Sandy
    =?Utf-8?B?U2FuZHk=?=, Aug 3, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?U2FuZHk=?=

    Ryan Ternier Guest

    Sandy wrote:
    > Hello -
    >
    > I have a little application that I would like to have an exit button on that
    > closes my web application and closes Internet Explorer.
    >
    > What is the code that will do that?
    >
    > Any help will be greatly appreciated!
    >


    You could use: this.window.close(); (JavaScript)
    But that won't work in all browsers, and depending on the Security level
    of the browser, it will always prompt the user, or just ignore it.

    /RT
    Ryan Ternier, Aug 4, 2005
    #2
    1. Advertising

  3. Everything in the HTML document belongs to you. JavaScript also gives you
    the ability to manipulate some things in the browser itself, things that are
    temporary properties of the window, and only a few things, as the browser
    window really belongs to the user. The further away you get from the HTML
    document itself, the less likely you are going to have control, and that is
    a good thing. The HTML document is a guest on the user's computer. A good
    guest doesn't try to rearrange the furniture in the host's home.

    However, some guests are just plain rude. They are like door-to-door
    salemen, who, when you try to close your front door, stick their foot in the
    crack, to prevent you from doing so. The Internet is full of all kinds of
    people, from the best to the worst. Porn sites have been among the worst
    offenders, but other "sales" - type sites have followed suit, with pop-up
    ads that open other pop-up ads, windows that hide themselves, etc., in
    effect, trying to force the user to do something they do not want to, like a
    bad guest. So, browser and Operating System manufacturers have been working
    on ways of preventing these bad guests from rearranging your furniture
    without your permission, while still enabling HTML documents to be helpful
    and useful in as many ways as possible. This is a difficult task, as one
    goal seems to run against the other, and both are equally desirable.

    Now, here's where I'm going with this: The user has opened a browser window
    on his/her computer, to browse the Internet. He/she may want to use that
    same browser window to go somewhere else when he/she is through with your
    web site. Now, there are JavaScript functions like window.open() and
    window.close() that can be used by an HTML document to open a new browser
    window (similar to a dialog box, or help window, for example), or close a
    browser window that it has opened. In fact, the JavaScript window.close()
    method used to be able to close the window which the user opened, and, in
    some browsers, still can, with a bit of tweaking.

    However, when designing a web site, or a web application (which is, to the
    user, the same thing), one must be aware of these issues, and sensitive to
    the user's desires, if one wants to generate traffic to one's web site, and
    keep people coming back. In other words, one must be a good guest in order
    to be invited back.

    Among the changes that have been made are changes to the window.close()
    method. A window that has been opened by an HTML document using the
    JavaScript window.close() method can close itself, with no problems. It can
    also be closed by the window that opened it. But a window that the user has
    opened may or may not be able to close itself. In most cases, the browser
    will prompt the user first, ask permission to close the window, like a good
    guest.

    Now, there is a workaround for this, as with most programming technologies.
    How does the browser know who opened it? It has a public property called
    "opener" which is a browser window. When the user opens the window, the
    opener is null. When an HTML document opens a window, the opener is the
    window that opened it. So, you can usually set the "opener" property to the
    current window, and this will fool (at least) most browsers. Example:

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

    However, I would not be surprised if, at some near point in the future, this
    property was made read-only by browser manufacturers, as they are aware of
    this trick, and I can't think of a single reason why it should be settable,
    except by the browser software, other than to spoof the browser as I have
    illustrated above.

    Now, the reason I've gone into all of this is that, when designing a web
    application, one should be sensitive to the needs and desires of the user.
    Otherwise, one will not have very many users. So, a good rule of thumb is,
    be a good guest. Don't try to mess too much with the user's browser. Use
    what you know wisely, and don't abuse your power!

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Everybody picks their nose,
    But some people are better at hiding it.


    "Sandy" <> wrote in message
    news:...
    > Hello -
    >
    > I have a little application that I would like to have an exit button on
    > that
    > closes my web application and closes Internet Explorer.
    >
    > What is the code that will do that?
    >
    > Any help will be greatly appreciated!
    >
    > --
    > Sandy
    Kevin Spencer, Aug 4, 2005
    #3
  4. =?Utf-8?B?U2FuZHk=?=

    Diane Wilson Guest

    In article <>,
    says...

    <snip>

    > Now, the reason I've gone into all of this is that, when designing a web
    > application, one should be sensitive to the needs and desires of the user.
    > Otherwise, one will not have very many users. So, a good rule of thumb is,
    > be a good guest. Don't try to mess too much with the user's browser. Use
    > what you know wisely, and don't abuse your power!


    Thank you, Kevin, that was said much more politely than the response I
    was considering.

    In usability, there is a heuristic known as the "rule of least surprise"
    which basically says not to do anything that the user doesn't expect
    you to do. Software that tries to anticipate what a user might do will
    often guess wrong, and usually in ways that are very irritating.
    Software that assumes "I know better" when it's messing with things in
    the user's domain will almost always get it wrong.

    Diane
    Diane Wilson, Aug 4, 2005
    #4
  5. Thanks All for your responses.

    I guess I was unclear as to the context of my usage of this. I have a
    little "demo" that is opened by a user clicking a link that I supply. When
    the demo is over, I wanted to clean up after myself by giving them a button
    they can click on to exit.

    Is there anything wrong with this being used for this particular purpose?

    --
    Sandy


    "Sandy" wrote:

    > Hello -
    >
    > I have a little application that I would like to have an exit button on that
    > closes my web application and closes Internet Explorer.
    >
    > What is the code that will do that?
    >
    > Any help will be greatly appreciated!
    >
    > --
    > Sandy
    =?Utf-8?B?U2FuZHk=?=, Aug 4, 2005
    #5
  6. > Is there anything wrong with this being used for this particular purpose?

    Not at all. Anything that gives control to the user is welcomed by the user.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Everybody picks their nose,
    But some people are better at hiding it.

    "Sandy" <> wrote in message
    news:...
    > Thanks All for your responses.
    >
    > I guess I was unclear as to the context of my usage of this. I have a
    > little "demo" that is opened by a user clicking a link that I supply.
    > When
    > the demo is over, I wanted to clean up after myself by giving them a
    > button
    > they can click on to exit.
    >
    > Is there anything wrong with this being used for this particular purpose?
    >
    > --
    > Sandy
    >
    >
    > "Sandy" wrote:
    >
    >> Hello -
    >>
    >> I have a little application that I would like to have an exit button on
    >> that
    >> closes my web application and closes Internet Explorer.
    >>
    >> What is the code that will do that?
    >>
    >> Any help will be greatly appreciated!
    >>
    >> --
    >> Sandy
    Kevin Spencer, Aug 4, 2005
    #6
  7. =?Utf-8?B?U2FuZHk=?=

    Diane Wilson Guest

    In article <>,
    says...
    > Thanks All for your responses.
    >
    > I guess I was unclear as to the context of my usage of this. I have a
    > little "demo" that is opened by a user clicking a link that I supply. When
    > the demo is over, I wanted to clean up after myself by giving them a button
    > they can click on to exit.
    >
    > Is there anything wrong with this being used for this particular purpose?
    >
    >

    No, in a window that the same app created, it's not a problem, although
    I'd more than likely use the close box on the window frame.

    Some of us have dealt with enough bad web applications that we get a
    little skittish, is all.

    Diane
    Diane Wilson, Aug 4, 2005
    #7
  8. Thanks again, All!!
    --
    Sandy


    "Sandy" wrote:

    > Hello -
    >
    > I have a little application that I would like to have an exit button on that
    > closes my web application and closes Internet Explorer.
    >
    > What is the code that will do that?
    >
    > Any help will be greatly appreciated!
    >
    > --
    > Sandy
    =?Utf-8?B?U2FuZHk=?=, Aug 5, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?a3N0cml5aG9u?=

    Open new Internet Explorer window from web service or Web App

    =?Utf-8?B?a3N0cml5aG9u?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,189
    Kevin Spencer
    Aug 3, 2005
  2. cmay
    Replies:
    0
    Views:
    1,129
  3. Replies:
    7
    Views:
    1,524
    Procyon
    Feb 9, 2008
  4. Ed Hauptman
    Replies:
    7
    Views:
    1,014
    Ed Hauptman
    Aug 7, 2009
  5. John Smith
    Replies:
    1
    Views:
    139
    Evertjan.
    Mar 12, 2005
Loading...

Share This Page