You must Sign In to post a response.
  • Category: ASP.NET

    How to get browser close event

    How to get browser close event in asp.net. I have tried but no results
  • #709661
    <script type="text/javascript">
    2
    window.onbeforeunload = function(e) {
    3
    // check condition
    4
    return ' your message .';
    5
    };
    6

    7
    </script>

    I Hope To Use Full..
    And Choice The Best Answers

    php-wordpress Developer
    you can any problem to php wordpress to contact me
    jivanibhai7306@gmail.com
    Thanks!!...

  • #709677
    Hi,

    <script type="text/javascript">

    window.onbeforeunload = function(e) {

    // check condition
    return ' your message .';
    };

    </script>

    every one says above javascript code is work. i thinks its not work in chrome and IE also some version will not support because security reasons. i feel its not easy way get solution for this. if any one find solution they are welcome.

    Regards,
    Kalandiyur Subramanian Mohan
    www.mohanks.com

  • #709704
    Hi,

    You can use javascript to raise close function using önunload event.

    function close()
    {
    //write your closing logic here
    alert("Window is closing...");

    }
    <body önunload="close()">


    Hope it will be useful.

    Regards,
    T.N. THEAAVARAAJ
    Senior Software Engineer,
    Microsoft Certified Technology Specialist.
    Email:devabe2005@gmail.com

  • #709736
    HI,
    To close the window, you can user the window.close() in java script.

  • #709738
    Hi.,

    Yopu can use the beforeunload event in javascript you can get the browser closing event.



    window.onbeforeunload = function(event) {

    event = event || window.event;

    var confirmClose = 'Are you sure?';

    if (event) {
    event.returnValue = confirmClose;
    }

    return confirmClose;

    }


    Regards,
    Gandhi

  • #709747
    If i used the above script some problem comes when i press refresh..If i press refresh onbeforeunload calling.

  • #709922

    $(document).ready=function(){
    window.onunload=function(){alert("closing");};
    };

    Thanks,
    Sini
    "Always Ready to accept challenges....."

  • #709948
    hi,

    Please check nice one..

    http://www.codeproject.com/Questions/255878/Catch-Browser-close-event

    Regards
    Raj


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.