rnaud
rnaud

Reputation: 2622

Close event in Safari iphone?

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

Answers (3)

Lazarus
Lazarus

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

Vincent Robert
Vincent Robert

Reputation: 36120

Did you try the unload event?

jQuery documentation on the unload event

Upvotes: 0

rnaud
rnaud

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

Related Questions