What is that event that triggers when a web-page looses focus or gets close? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is that event that triggers when a web-page looses focus or gets close?

For example when you are on a banking site, and by mistake you click on the close button, it confirms that all the changes will be lost upon closing the page. So what's that event that triggers here? JavaScript course has talked about confirm here but not that event

21st Jul 2017, 4:01 PM
Siddharth Saraf
3 Answers
+ 4
Try this (link the jQuery firts) : $(document).ready(function() { $(window).bind('beforeunload', function () { return 'Are you sure want to leave this page?'; }); });
21st Jul 2017, 5:09 PM
Mugfirfauzy Siregar
Mugfirfauzy Siregar - avatar
+ 2
try "onbeforeunload"
21st Jul 2017, 4:06 PM
Вап
+ 2
is that onblur?
21st Jul 2017, 4:06 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar