W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <div id="result"></div> <script> // 检查浏览器支持 if (typeof(Storage) !== "undefined") { // 存储 localStorage.setItem("lastname", "Smith"); // 取回 document.getElementById("result").innerHTML = localStorage.getItem("lastname"); } else { document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage..."; } </script> </body> </html>