I recently developed a script to highlight text in a web page based on document.execCommand() but the changes are gone if I refresh my web page.
How can I keep the change for every user ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As I am rather unsure what you actually want to persist I will give some generic information.
Some good reading at DiveIntoHtml5 on storage.
I would suggest taking a look at either
sessionStorageorlocalStoragenow while these are regarded generally asHTML5the browser support is much greater.You can see the support of
keyValueStorageat CanIUseYou can store a key / value pair as follows:
You can then retrieve the value as follows:
Remove:
sessionStorageworks the same as above but will only persist while the browser is open. It persists for the “session” of the browser. HoweverlocalStoragewill persist until it is removed by code or by clearing the browser.