- localStorage 本地离线存储 浏览器关闭后数据不丢失。
<script type="text/javascript"> if (
localStorage.pagecount
) { localStorage.pagecount=Number(localStorage.pagecount
) +1; } else {localStorage.pagecount
=1; } document.write("Visits "+localStorage.pagecount
+ " time(s)."); </script> - sessionStorage 浏览器关闭后自动删除。
<script type="text/javascript"> if (
sessionStorage.pagecount
) { sessionStorage.pagecount=Number(sessionStorage.pagecount
) +1; } else {sessionStorage.pagecount
=1; } document.write("Visits "+sessionStorage.pagecount
+" time(s) this session."); </script> - cookies,sessionStorage 和 localStorage
-
- cookie在浏览器和服务器间来回传递。 sessionStorage和localStorage不会
- sessionStorage和localStorage的存储空间更大;
- sessionStorage和localStorage有更多丰富易用的接口;
- sessionStorage和localStorage各自独立的存储空间;
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容