rrrfusco
rrrfusco

Reputation: 1119

Keep Text in TextArea in Chrome Extension Popup

Chrome extension popups are designed per the FAQ to close when clicked away from.

I have a firefox add-on that will remember the text typed into the text area when the popup is clicked open or closed.

I assume this is the case because the popup merely opens and closes the html, as opposed to the chrome version which calls window.onload each time.

The chrome extension popup however seems to call popup.js each time you click the icon, which I assume is because popup.js is linked from popup.html because page scripts have to be "moved out" in chrome for security.

Is there a way to keep data typed into a textbox, when the extension reloads and "erases" the text?

Upvotes: 0

Views: 589

Answers (1)

abraham
abraham

Reputation: 47833

Anytime the content of the textarea changes, store the new value in localStorage. When the popup loads again, check local storage for a value and populate the textarea.

Upvotes: 1

Related Questions