I open a new window by clicking on the extension button next to the search bar. I would like to open a new window only if it is not already open; in this case, I would rather show the old one.
Here is my code, but it does not work.
var v = null; var vid = null; chrome.browserAction.onClicked.addListener(function(tab) { chrome.windows.getAll({}, function(list) { // check if already exists for(window in window_list) if(window.id == vid) { window.focus(); return; } chrome.windows.getCurrent(function(w) { v = chrome.windows.create({'url': 'my_url', 'type': 'panel', 'focused': true}); vid = w.id; }); }); });
Can someone explain to me how to fix this?
Most likely, after closing the application, the v and vid values ββare deleted (after the script is finished), but how can I fix it? If possible, without using localStorage or cookies.
I tried to specify the tabId properties when creating the window, but this will not work. I also tried using the chrome.windows.onRemoved.addListener functionality, but it does not work either.
auino source share