0

My problem is, when user clicks the close browser/current-tab some cookies need to be deleted.

using jquery, onbeforeunloadfired and showing Leave this page and Stay on this page.

How to get which button clicked by user?

how to delete the cookie?

techfoobar
  • 65,616
  • 14
  • 114
  • 135
Natesan
  • 1,135
  • 2
  • 14
  • 21
  • `onbeforeunload` is not provided by jQuery. You should add the JavaScript tag as well. – techfoobar Jul 03 '13 at 08:47
  • [javascript before leaving the page](http://stackoverflow.com/questions/7080269/javascript-before-leaving-the-page) - can help you. – Paritosh Jul 03 '13 at 08:49

3 Answers3

0

If it return a string, it's "true".

The question has already been answered here :

jQuery UI Dialog OnBeforeUnload

Community
  • 1
  • 1
Antoine
  • 355
  • 2
  • 12
0
  $(window).on('beforeunload', function(e) {  
       return 'Are you sure you want to leave?';
    }); 


    $(window).unload(function(){
      // do something..
    });
Aisha
  • 358
  • 1
  • 3
  • 12
0

Maybe sessionStorage you can help? The sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the browser window. http://www.w3schools.com/html/html5_webstorage.asp

zloctb
  • 10,592
  • 8
  • 70
  • 89