Wednesday, July 16, 2008

Catch the browser window closed event and do something.

Simple method which listen to the browser closed event by close button and performs some operations.

  1. Subscribe to the Body.onload using function init()

    <body onload="init();" >
    sample page

  2. Subscribe to the onunload event of window object

    function init ( url )

  3. Do the oprations in the event handler

    function unloadwindow(e)
    alert("unloaded window / closed");
    //Perform your operations here

No comments: