Search code examples
jquerygoogle-chrome-extensionjquery-events

in a Chrome extension is there a way to programmatically 'click' the pageAction button


I have a Chrome extension with a pageAction button. The user clicks on it and the popup.html window shows up so the user can do the needful.

Is there a way that I can decorate a link on the page such that when the user clicks the link it programatically fires a click event to the pageAction button so the popup.html opens.

Using jQuery it is trivial to fire such an event on elements in the page i.e. $("#myelement").click() but how does one get the handle of a pageAction element so one can fire a click event on it?


Solution

  • Unfortunately you cannot directly trigger it, in the same way that you cannot trigger a browser action programmatically. This is by design, Chrome is fairly restrictive with extension UIs in an attempt to keep them all standardised and minimalist.