HTML5中的本地Web存储示例
例如,设置一个本地存储变量,并在每次访问此页时访问该变量,即使下次打开窗口时也是如此
<!DOCTYPE HTML> <html> <body> <script type="text/javascript"> if (localStorage.hits) { localStorage.hits = Number(localStorage.hits) + 1; } else { localStorage.hits = 1; } document.write("Total Number of Hits :" + localStorage.hits); </script> <p>Refresh the page to increase number of hits.</p> <p>Close the window and open it again and check the result.</p> </body> </html>
HTML5中的本地Web存储
- 本地存储用于存储客户端的键值对。
- 每个浏览器的本地存储不是每台计算机
- 本地存储对象存储无效日期的数据。
- 本地存储专为跨越多个窗口的存储而设计,并持续超过当前会话。
- 当浏览器关闭时,将不会删除本地存储数据,并将在第二天,周或者年内提供。
- 每个浏览器的本地存储不是每台计算机
- 浏览器中的本地存储可用于具有相同源(域)的所有窗口。
- HTML5介绍了本地storage属性,该属性将用于访问页面的本地存储区域而无需使用时间限制。
日期:2020-04-11 23:04:11 来源:oir作者:oir