Trying to perform a series of actions on page unload, but the pages unloads too fast to finish them.
Posted
by user138821
on Stack Overflow
See other posts from Stack Overflow
or by user138821
Published on 2010-06-07T05:39:45Z
Indexed on
2010/06/07
5:42 UTC
Read the original article
Hit count: 207
I have a series of actions I want to perform on page unload. Namely if a user is editing an input field, and they refresh or close browser or leave page, I want to save the contents of the field.
The actions don't include an AJAX call, so I can't just make it synchronous. It's actually saving to local storage, but the page unloads before the storage can take place. The code is correct, if I add an alert to the actions, the delay allows the rest of the code to finish before it even displays.
Any ideas?
Thanks!
© Stack Overflow or respective owner