我正在为类(class)作业制作一个基本的在线编辑界面(类似于 Microsoft 大纲),我希望在用户重新启动系统时存储大纲的详细信息。我该怎么做?
<html>
<head>
<title>Editor</title>
<link rel="stylesheet" href="stylesheet.css">
<script src="script.js"></script>
</head>
<body>
<header>
<div class="navBar">
</div>
</header>
<textarea id="myTextArea">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent semper in nunc at mattis. Suspendisse metus augue, pellentesque finibus luctus dictum, tempor id nunc.
</textarea>
</body>
</html>
最佳答案
大纲是指文本区域吗? 您将需要一个按钮并在单击时,该按钮应将文本区域存储到 localStorage。
查看更多Storing a string with Javascript
@编辑
Localstorage 将只保存用户浏览器上的信息(如果他更换电脑,信息就会丢失),如果您需要始终保留它,则需要一个运行中的服务器来保存数据。
参见:Step by step using Nodejs to run a server with MongoDB and Express
关于javascript - 重新启动用户计算机后记住大纲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58919704/