html5下localstorage在IE下本地不能取值问题

时间:2022-08-26 08:27:03
情况是这样的,我如果把项目部署在tomcat中,然后访问页面,页面中的值从localstorage.getItem()是可以取到的,但是如果在本地html的形式直接调用js在IE下连localstorage对象都获取不到.我用的IE10,求告知解决方法,很急.谢谢.

2 个解决方案

#1


给你推荐一篇博客:http://blog.sina.com.cn/s/blog_4515673f0100mm6m.html
http://blog.sina.com.cn/s/blog_4515673f0100mm6m.html

#2



<!DOCTYPE HTML>
<html>
<body>

<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> 

<p>刷新页面会看到计数器在增长。</p>

<p>请关闭浏览器窗口,然后再试一次,计数器会继续计数。</p>

</body>
</html>

http://bbs.csdn.net/topics/390307938?page=1

#1


给你推荐一篇博客:http://blog.sina.com.cn/s/blog_4515673f0100mm6m.html
http://blog.sina.com.cn/s/blog_4515673f0100mm6m.html

#2



<!DOCTYPE HTML>
<html>
<body>

<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> 

<p>刷新页面会看到计数器在增长。</p>

<p>请关闭浏览器窗口,然后再试一次,计数器会继续计数。</p>

</body>
</html>

http://bbs.csdn.net/topics/390307938?page=1