I am trying to use sessionStorage on a page but it is giving me an error. Here is the code:
<script type="text/JavaScript">
sessionStorage.setItem("classname", "value1");
sessionStorage.setItem("classdesc", "value2");
</script>
The error I get from firebug console is: Operation is not supported" code: "9
When I try to use localStorage it works fine, so why does sessionStorage cause an error?
I am trying to use sessionStorage on a page but it is giving me an error. Here is the code:
<script type="text/JavaScript">
sessionStorage.setItem("classname", "value1");
sessionStorage.setItem("classdesc", "value2");
</script>
The error I get from firebug console is: Operation is not supported" code: "9
When I try to use localStorage it works fine, so why does sessionStorage cause an error?
Share Improve this question edited Dec 8, 2010 at 2:11 bjo asked Dec 8, 2010 at 1:50 bjobjo 5502 gold badges8 silver badges15 bronze badges 2-
Does using
window.sessionStorage
show the same problem? – Matt Ball Commented Dec 8, 2010 at 2:21 - Are you loading via file:///? yuilibrary./projects/yui3/ticket/2529165 – Kevin Hakanson Commented Dec 8, 2010 at 3:53
1 Answer
Reset to default 8The only thing I can think of is that "the page isn't ready", try placing this code at the end of the body section
<html>
<head></head>
<body>
<!-- YOUR PAGE HERE -->
<script type="text/JavaScript">
sessionStorage.setItem("classname", "value1");
sessionStorage.setItem("classdesc", "value2");
</script>
</body>
</html>
Final Answer: sessionStorage wont work in "local mode", but it will work if you upload the file to a server.