我创建了 Google Chrome 扩展程序。我的后台页面的脚本文件 (background.js) 中有一些状态变量
关闭并重新打开浏览器后,该变量的值不会重置。关闭浏览器后如何重置这些变量。
我创建了 Google Chrome 扩展程序。我的后台页面的脚本文件 (background.js) 中有一些状态变量
关闭并重新打开浏览器后,该变量的值不会重置。关闭浏览器后如何重置这些变量。
If js variables in the background page keep their values, that means the chrome process has not exited. Probably some chrome window is still open. Maybe you have developer tools for the background page open?
If don't find any chrome window that's still open, check for the chrome process using task manager if you are using windows, or with ps in other environments. If the process is still running there maybe something that's preventing from ending properly.
chrome.windows.onRemoved.addListener(function(windowId) {
Init(); });
function Init() { //clear variables }