First things first, read the Architecture Overview of Chrome extensions.
A popup page is a "throwaway" page that only exists as long as the popup is open; you cannot influence that. As soon as the popup loses focus, its HTML document will be destroyed.
In contrast, a background "page" (which usually has no HTML markup, hence the typical use of "scripts"
instead of "page"
) with "persistent": true
exists as long as Chrome runs. As such, it can hold state information. But it's an invisible page.
The right approach would be to make the popup page dynamic, save its state to background and/or various storage APIs, and restore state when opening.
Minimal example:
// popup.js
// Suppose #myInput is a text input
document.addEventListener('DOMContentLoaded', function() {
chrome.storage.local.get({setting: "default value"}, function(data) {
var inputElement = document.getElementById("myInput");
inputElement.value = data.setting;
inputElement.addEventListener("input", function(e) {
chrome.storage.local.set({setting: e.target.value});
});
});
});