onunload

Discussion in 'ASP .Net' started by Guest, May 20, 2005.

  1. Guest

    Guest Guest

    I am trying to capture when the user clicks the X button on the ie window. I
    have used the onunload for the window event, but there is a problem. I put
    javascript code for this event and when the form performs a postback on the
    page, the onunload event gets triggered eventhough I am still on the same
    page and the user did not click the 'X' button. In other words, the onunload
    event is triggered when you are performing a postback to the page. Is there
    anyway around this? I want to capture when the user clicks the 'X' and not
    when the page is performing a postback...

    thanks in advance...
     
    Guest, May 20, 2005
    #1
    1. Advertisements

  2. Guest

    John Guest

    If you are only using this for the X button, why not put the script in the X
    buttons onclick event?

    If you need if for other times, leave the functionality in the unload event,
    and set a flag in the X button onclick event.

    Also, be aware that if the form has validation and validation fails, you may
    still be looking at a problem. I have managed to overcome the clientside
    validation of the asp.net validation controls by using the following in the
    onclick event :

    if("none" != valSummary.style.display)
    {
    // perform my unload functionality.
    }

    Good luck,
    John MacIntyre
    http://www.johnmacintyre.ca
    Specializing in; Database, Web-Applications, and Windows Software
     
    John, May 22, 2005
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.