如何起草文本,客户端编程 [英] How to draft text, client side programming
本文介绍了如何起草文本,客户端编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好吧
我将description.txt的文本保存到document.cookie
我想将用户的文本保存为草稿。
问题是:
当用户关闭浏览器时,cookie被删除
如果输入在文本中,输入未保存在cookie中
你有更好的解决方案吗?
我尝试过:
我的代码保存在cookie中的文字
Hi everybody
I save the text of the description.txt into document.cookie
I want to save the user's text as a draft.
The problems are:
When the user closes the browser, the cookie is deleted
If the enter is in the text, the enter is not saved in the cookie
Do you have a better solution to my problem?
What I have tried:
My code save text in the cookie
function draft() {
document.cookie = document.getElementById("
<%=Description_txt.ClientID%>").value;
return false();
}
推荐答案
浏览器关闭时通常会删除Cookie - 如果你不想要,你需要设置到期日更合理的价值: HTML DOM cookie Property [ ^ ] - 但是整个文档往往会变得很大,这可能会影响网站的表观速度。您可能需要考虑使用HTML5 LocalStorage: HTML5网络存储 [ ^ ]
Cookies are normally deleted when the browser closes - if you don;t want that, you need to set the expiry date to a more reasonable value: HTML DOM cookie Property[^] - but a whole document will tend to get qute large, and that may impact the site's apparent speed. You might want to consider HTML5 LocalStorage instead: HTML5 Web Storage[^]
这篇关于如何起草文本,客户端编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文