2
Situation
I have a system in which I need the user to be dropped when closing the browser.
Code
in this way I was able to catch the closing of the browser, or better to say the 'exit' of the page for a new ( or not in case of browser closure ). But it is blocking me in the confirmation.
var myEvent = window.attachEvent || window.addEventListener;
var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload'; /// make IE7, IE8 compatable
myEvent(chkevent, function(e) { // For >=IE7, Chrome, Firefox
var confirm = window.confirm('Deseja fazer logout?');
if(confirm){
logout();
}
});
function logout (){
console.log('Logout');
}
Error
Blocked confirm('Do you want to log out?') During beforeunload
Someone would have another way to effect this functionality?
What do you mean
Porém está me barrando na confirmação
?– Sergio
Would the method I call
window.confirm()
he blocks by being inbeforeunload
. Confirmation would be the user’s reply whether or not to logout, I want to treat and below make the decision to go to my logoff or continue on the page.– ralfting
What do you use to keep the user connected to the system? sessions ?
– Gabriel Rodrigues
is by Cookies I use TOKEN. But my problem itself is not to dislodge but the function inside. = D
– ralfting
Good evening, I wonder if the answer helped you, if not please comment on what you think is missing.
– Guilherme Nascimento