Looking at the title of the topic, you must be wondering, is it something really related to Dynamics CRM. Well I would say a big Yes. Because it is an excellent HTML 5 feature and we develop HTML 5 webresources in our day-day activities. Being a dynamics crm consultant we sometimes tend to miss out on some cool stuffs outside our CRM universe. For those who have missed out this one, I bet you would love it.
Many a times when we open a HTML webresource on the click of a ribbon button or some element click on the CRM entity form, we tend to pass parameters to the webresource. And sometimes we need to persist the value of the parameter in the webresource even if the webresource is refreshed.
Well you can use the cool HTML 5 feature of sessionStorage.
The sessionStorage persists as long as the browser window is open and gets deleted once you close the browser tab/ window. Another cool stuff about this is that it follows the standard key/ value model of storing the value just like any modern language.
Below is the sample code of how to set and get values from the sessionStorage.
It will persist your page refresh and unlike cookies it does not get posted to the server every time you submit your page.
Hope this helps!