Why does saving a text field value in sessionStorage cause IE8 to crash?

I created a simple example to demonstrate this.

<input id="search" type="text">

var input = document.getElementById('search');
window.sessionStorage.setItem('test', '');
alert(input.value === '');
window.sessionStorage.setItem('test2', input.value);
alert('complete');

Running this in IE8 crashes the entire browser when saving input.valuewith a standard error - "Internet Explorer has encountered a problem and needs to close ...".

The same thing happens with localStorage.

JSFiddle demo here

+4
source share
2 answers

I came across this too, although it took me a few minutes to figure out what caused it, and not our IE8 placeholder widget, knockout.js or modernizr bindings. Our text box was <input type="search" .../>, and that is not a problem either.

, IE8, . , , :

window.sessionStorage.setItem('test2', input.value || '');

... , IE8 .?

+1

:

if(value)
    localStorage.setItem(name, value);
else if(localStorage.getItem(name))
    localStorage.removeItem(name);  

, - , .

+1

All Articles