Posts Tagged ‘HTML5’
* HTML 5 and sessionStorage
Posted on February 19th, 2010 by Dave Johnson. Filed under JavaScript, quirks.
We came across a strange bug today that was being caused by our recent addition of sessionStorage to our application.
The Mozilla Developer Center says this about sessionStorage:
This is a global object (
sessionStorage) that maintains a storage area that’s available for the duration of the page session. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated.
Emphasis mine.
What we found was that of the three different browsers that currently “support” sessionStorage, there are three different implementations. Go figure.
I looked at a few different ways of opening new windows or tabs and those included anchor tags with target values of “” and “_blank”, window.open() JavaScript calls with different targets, and context menu open in new window or tab.
Internet Explorer 8 is furthest from the spec, as one might expect. No matter how you opened a new window from the page, the sessionStorage is preserved in the new window.
Firefox is only slightly better in that it does not preserve the sessionStorage in new windows when the new window is created by choosing open in new window / tab from the context menu on an anchor.
Safari is more or less like Firefox except that it does not preserve the sessionStorage when the target on an anchor is “_blank”.
In short, if you are expecting that sessionStorage is tied to a single browser window then think again.
Recent Posts
- BlackBerry JavaScript Oddities
- JavaScript Event Merging
- Smart Grid Utilities
- PhoneGap Desktop
- Crockford Facts
Archives
- July 2010
- June 2010
- April 2010
- March 2010
- February 2010
- January 2010
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
