Very simple notes plugin/script

Hi there,

I’m wondering if there are any very simple JS plugins/scripts that allow users to leave notes in a text box and remain there when closing the page/refreshing?

This is for a personal project and will be offline, so it doesn’t need any login/security aspects.

Thanks

Here’s a very simple notes script.

1 Make a place for the notes.

    <textarea class="notes"></textarea>

2 Move it to the right, and make it look a bit better.

.notes {
  position: absolute;
  right: 1em;
  border: 1px solid grey;
  background: khaki;
}

3 Use these cookie handling functions.

4 When the page loads, read the notes from the cookie.

var notes = document.querySelector(".notes");

window.addEventListener("load", function(evt) {
  notes.innerHTML = readCookie("notes");
});

5 When you change the notes, update the cookie.

notes.addEventListener("change", function(evt) {
  createCookie("notes", notes.value, 0);
});

That’s about as simple as it gets.

EDIT
typo corrected

Minor typo…

.notes {
    ...
}
1 Like

Thanks - I’ll contact someone to make the appropriate update.

Thank you for the help :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.