W3CAPI 实例工具箱
运行代码
源代码
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <p>刷新页面会看到计数器在增长。</p> <p>请关闭浏览器窗口,然后再试一次,计数器会继续计数。</p> <script type="text/javascript"> if (localStorage.pagecount) { localStorage.pagecount=Number(localStorage.pagecount) +1; } else { localStorage.pagecount=1; } document.write("访问次数: " + localStorage.pagecount + " 次"); </script> </body> </html>
运行结果