Reputation: 3151
I'm making an extension that gets the user current selection, uses it to change popup.html and shows it to the user. I would like to be able to do a couple things:
Any suggestions?
Upvotes: 4
Views: 1280
Reputation: 111315
I think Page Action would better suit your needs as you will be able to hide popup icon completely. Otherwise you can make popup body disappear using:
chrome.browserAction.setPopup({popup: ""});
As to your first question - there are two options. If popup html remains pretty much the same all the time (like a template), only data changes - you can pass the data using GET url parameters before the popup is clicked using:
chrome.pageAction.setPopup(tabId, popup: {"popup.html?param=value&..."});
(in the popup you would need to parse url to get the data). If there are several different popup styles, you can use this method as well to switch between different files.
In case popup html is completely different each time, you can prepare popup html in the background page when a user makes selection, and then pass ready to display html when popup opens.
Upvotes: 4