how logout when close the browser tab in JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how logout when close the browser tab in JavaScript

Window.onbeforeunload function not working

8th Jul 2020, 8:57 PM
SGB
4 Answers
+ 3
SGB Here is an example from w3schools https://code.sololearn.com/W6gheChtG0mW/?ref=app
8th Jul 2020, 10:55 PM
BroFar
BroFar - avatar
0
SGB can you please show us your code including the above function as there are some whom can clarify this issue. Thanks and happy coding
8th Jul 2020, 9:17 PM
BroFar
BroFar - avatar
0
@BroFar here my code something look like: window.onbeforeunload = function(event) { var isOK = confirm("Are you sure to Leave this Page?"); if(isOK) { LogoutFuncton(); } } function LogoutFuncton (){ top.location.href= logouturl }
8th Jul 2020, 10:39 PM
SGB
0
BroFar I need to destroy the session when user close the tab without logout
10th Jul 2020, 8:35 AM
SGB