我有一个网站,我希望用户能够提交我可以查看的文本,然后作为人们无法编辑的文本发布。我具有编写和保存信息以备后用的功能,但我无法访问该文本。
这是简化为文本输入和保存部分的代码(其余的是样式和其他部分):
<html>
<head>
<title> Submit Text </title>
<script type="text/javascript">
function saveEdits() {
//get the editable element
var editElem = document.getElementById("edit");
//get the edited element content
var userVersion = editElem.innerHTML;
//save the content to local storage
localStorage.userEdits = userVersion;
//write a confirmation to the user
document.getElementById("update").innerHTML="- Edits saved!";
}
function checkEdits() {
//find out if the user has previously saved edits
if(localStorage.userEdits!=null)
document.getElementById("edit").innerHTML = localStorage.userEdits;
}
</script>
</head>
<body onload="checkEdits()">
<p>
<div id="edit" contenteditable="true">
<p>
Here is the element's original content
</p>
</div>
<p>
<input type="button" value="save my edits" onclick="saveEdits()"/>
<div id="update"><p> - Edit the text and click to save for next time</div></p>
</body>
这是我网站的链接,如果你想看看我在说什么: https ://chattah.neocities.org/ChattahStory.html
这是我一直在开发的网站的一项新功能
我缺少什么能够收集数据?我真的不想转向 PHP,因为网站主机不支持 PHP,但如果 PHP 是唯一的方法,那很好谢谢