HTML5 and its data storages

Hi All,

I am using HTML5 and its data storages i.e. sessionStorage and localStorage techniques to store data at client side only ( as I am using only .html pages in my site and communicating the backend with REST APIs only.)

My requirement is, if I am on my one of my domain page (http://localhost:8080/page1.html) and if accidently the tab or window closes(because of power cut off etc. reasons) then before closing it I want to clear localStorage data. I know this is possible with sessionStorage as it removes all data on this event but symulteniously I want to keep or pass the data from one page to another domain page as well in another tab which is not possible with this technique, so I am using localStorage to do that. BUT again as I mentioned previously, I want to consider the above condition as well.

Could you please let me know the solution.

Thanks in advanced!

Can you temporarily transfer the localStorage data to sessionStorage on each beforeunload event?