Reputation: 2622
Is there a way to know that the user is closing the navigator, and/or the tab in Safari for iPhone, so that I can save data to localStorage, or do I need to do it for every input ?
Upvotes: 0
Views: 2077
Reputation: 43074
Having looked at the documentation for localStorage, I think you need to be storing the relevant data as it's generated/modified rather than waiting for a close event. I realise this is probably more work than any of us would like but at least you can be sure that you are saving the current state at each point so that even a browser crash shouldn't kill your state.
Upvotes: 1
Reputation: 36120
Did you try the unload
event?
jQuery documentation on the unload event
Upvotes: 0
Reputation: 2622
Okay, it seems like onbeforeunload is a Microsoft invention, and so is not supported by Safari nor Opera.
I'm going to have to look for another way :)
Upvotes: 0