I know that this code will be triggered when you closing tab AND when you refresh the tab.
window.onbeforeunload = closingCode;
function closingCode(e) {
var evtobj = window.event ? event : e;
var callDateUTC = { callDateUTC: new Date().toUTCString() };
if (evtobj == e) {
//firefox
if (!evtobj.clientY) {
that._apiGateway
.post(that._apiGateway.ApiPaths.RefreshToken, callDateUTC)
.subscribe((loginResponse: LoginResponse) => {
});
}
}
else {
//IE
if (evtobj.clientY < 0) {
that._apiGateway
.post(that._apiGateway.ApiPaths.RefreshToken, callDateUTC)
.subscribe((loginResponse: LoginResponse) => {
});
}
}
return null;
}
But I want to know which of those two event was triggered...
if (tabWasRefreshed){
//code
}
else if(tabWasClosed){
//code
}