在Chrome扩展中有一种编程方式来'点击'pageAction按钮 [英] in a chrome extension is there a way to programatically 'click' the pageAction button

查看:101
本文介绍了在Chrome扩展中有一种编程方式来'点击'pageAction按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有pageAction按钮的Chrome扩展。用户点击它并弹出popup.html窗口,用户可以做必要的事情。

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.

有没有一种方法可以在页面上修饰链接当用户点击链接时,它会以编程方式将一个点击事件触发到pageAction按钮,以便popup.html打开。

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.

使用jQuery可以轻松地触发这样的事件$(#myelement)。click(),但是如何得到pageAction元素的句柄,以便可以触发点击事件呢?

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?

推荐答案

不幸的是,您无法直接触发它,就像您无法以编程方式触发浏览器操作一样。这是通过设计,Chrome对扩展UI的限制很大,试图使它们保持标准化和极简主义。

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.

这篇关于在Chrome扩展中有一种编程方式来'点击'pageAction按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆