I am using javascript function window detector onbeforeunload
but it does not detect event when I click browser "close X" button. Is it problem in my code or it is its default behavior?
$(window).on('unload onbeforeunload close', function (e) {
e = e || window.event;
if (e) {
if(localStorage.openpages==""||localStorage.openpages==null){
var params = {
isonline:0
}
$.ajax({
async: false,
type: "POST",
url: '<?= base_url()?>UserProfile/setonlinestatus',
data: params,
contentType: "application/x-www-form-urlencoded",
dataType: "json",
timeout: 60000,
success: function (response) {
alert("")
},
error: function (jq, status, message) {
var e = message;
}
});}
}});
//navigator.onLine it check whethe ri am online or not