How we can show the alert message while close the browser or close tab using JavaScript/Jquery


  • Hi All,

    I have a requirement to show the alert while close the browser or close tab . I have write below JavaScript code to achieve this functionality but window.unload” and “window.onbeforeunload” function but it’s not working in chrome.

    <script type="Javascript">

      window.onbeforeunload = function(e) {

          return 'Are you sure you want to leave this page?  You will lose any unsaved data.';



    I am onlooking for a solution.

    Thanks you in Advance !!

    Thanks & Regards

    Deepak chauhan


    SharePoint 2010 & 2013 and Office-365 Branding and Front End Customization, UI Design

    2018년 6월 11일 월요일 오전 9:11

모든 응답