javascript - Chrome onUnload event not triggering -


i have set in local storage (where tabid id of triggering tab [onupdated event])

var visited = {}; visited[tabid] = true; chrome.storage.local.set(visited); 

i wish change stored variable false when page unloads (which gather happens on refresh, moving new webpage or closing tab)

window.onunload = resetstorage;  function resetstorage() {      var visited = {};      chrome.tabs.query({ currentwindow: true }, function (result) {         result.foreach(function (tab) {             visited[tab.id] = false;             console.log(visited);             chrome.storage.local.set(visited);         });     }); }; 

but doesn't seem triggering (i can't console.log come out, not sure if can on unload event?) not change stored values.

what doing wrong?

as background keeping track of whether have run code on page doesn't trigger multiple times iframe loading or redirections (i think need additional code handle redirects).


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -