DEV Community

Discussion on: Sure you want to leave?—browser beforeunload event

Collapse
 
samthor profile image
Sam Thorogood

This feature exists on the web whether I write about it or not! :)

Hopefully this post has given some examples of when beforeunload is appropriate to use, and detailed a technical approach so that folks don't just generate warnings all the time. And you might also save your users' data—if a network request is still pending while a page is being closed, beforeunload can be useful to ensure that it does complete successfully.