Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

JavaScript
function draft() {
            document.cookie = document.getElementById("
            <%=Description_txt.ClientID%>").value;
            return false();
        }
Posted
Updated 28-Oct-17 20:48pm

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900