我知道当你关闭标签时以及刷新标签时会触发此代码。
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;
}
但我想知道这两个事件中的哪一个被触发了......
if (tabWasRefreshed){
//code
}
else if(tabWasClosed){
//code
}