Which function is called at the time of browser closing . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Which function is called at the time of browser closing .

at the time the user close the browser i want a function gets called and delete its data from database .

28th Aug 2018, 6:31 AM
Nilesh kumar
Nilesh kumar - avatar
2 Answers
+ 5
window.onbeforeunload = function(e) { e.returnValue = 'Please dont leave me.'; return e.returnValue; };
28th Aug 2018, 7:34 AM
Calviղ
Calviղ - avatar
0
sorry calvin but your code only works when i close the tab but it is not working when i close the browser.
28th Aug 2018, 10:35 AM
Nilesh kumar
Nilesh kumar - avatar