As chrome.browserAction.onClicked works only if there is no popup, is there any alternative method to fire a query when browser action icon is clicked?
Let me make myself clear..
I have more than one view i.e, html files in my extension. My default popup in index.html
Whenever I click on the icon I want to fetch some data from server. If I include this function in index.html or index.js, this function gets called every time I go to that page. Can anyone help me?
Thank you in advance.
What I would do is:
Have the behavior take place in the
onloadhandler of the page. Since it sounds like the default popup page,index.html, can be loaded as time when the user is not creating the initial popup, I would create a page that is a dedicated initial popup load page that is not used anywhere else. This page could redirect toindex.htmlor include it as an iframe.Another option is to have
index.htmltake a query string indicating how it is being used. Your initial popup could beindex.html?init=1and all other inclusions of the page simply useindex.html. Then usewindow.location.search.substring(1)to test if a query string is present and take the appropriate action.