Reputation: 3205
I have created a Google Chrome Extension with popup page and popup,js
I capture date from different pages, store them in localStorage and show on the popup page. So, I need to clear it every time I am on a different page, so that it should not show the previous value. I have tried various ways to clear localStorage like
by using window.onload and window.onbeforeunload. But, it is not working. Please help me by telling the way to do the same.
Upvotes: 0
Views: 362
Reputation: 178
It looks like you should use the onActivated event to figure out when the active tab changes. Put the code in you extension's background page.
chrome.tabs.onActivated.addListener(function callback)
Here is some more documentation: http://developer.chrome.com/extensions/tabs.html#event-onActivated
Upvotes: 1