I can't get LocalStorage to work on Internet Explorer 10.

The following test code (from http://www.w3schools.com/html/html5_webstorage.asp) works on Chrome and Safari.

Code:
<!DOCTYPE html>
<html>
<body>

<div id="result"></div>
<script>
if(typeof(Storage)!=="undefined")
  {
  localStorage.lastname="Smith";
  document.getElementById("result").innerHTML="Last name: " + localStorage.lastname;
  }
else
  {
  document.getElementById("result").innerHTML="Sorry, your browser does not support web storage...";
  }
</script>

</body>
</html>
When I try it on IE10 I get the following error:

SCRIPT5007: Unable to set property 'lastname' of undefined or null reference


The code first checks for browser support which IE10 shows positive.

I've tried windows.localStorage and document.localStorage without any luck.
In Options/Advanced menu, Enable local DOM storage is checked.

Any other tweaking I need to do to get it to work?

Thanks,