admin管理员组文章数量:1327112
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.
本文标签: javascripterror using sessionStorageStack Overflow
版权声明:本文标题:javascript - error using sessionStorage - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742202790a2432269.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论