I need to execute a certain method when the section is closed (when the user clicks close the browser). I'm working with JSP and I'm not sure how I can do this.
I need to execute a certain method when the section is closed (when the user clicks close the browser). I'm working with JSP and I'm not sure how I can do this.
You can try some things using Javascript and / or Jquery:
First mode:
You can use Jquery unload: link
Second mode:
Using a bind with javascript:
$(window).bind('beforeunload', function() {
alert("fechei");
});
Additional:
Try the following functions:
window.onbeforeunload = function(){alert("oi");}
window.addEventListener("beforeunload", function(e){alert("oi");}, false);
I hope I have helped.
Att