Life after onUnload event

Discussion in 'Javascript' started by samug, Jul 20, 2004.

  1. samug

    samug Guest

    Can I do something just before or after the unload event is fired?
    I want to submit a form just before the user leaves the page.

    I have somtehing like this:
    ....
    <script language="JavaScript"><!--
    function leavingPage() {
    window.document.leavingForm.submit();
    //return true;
    }

    --></script>
    ....
    <BODY onUnload="leavingPage()">
    <form action="<%= request.getRequestURI() %>" method="post" name="leavingForm">
    <input type="hidden" name="leaving" value="true">
    </form>

    The thing I want to do is if the user goes away from a page I reset
    some variables in JSP. I just want to know if user goes away from the
    page.

    Thanks,
    Shmuel.
     
    samug, Jul 20, 2004
    #1
    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.