简体   繁体   English

如何触发chrome.tabs onClick事件

[英]how to trigger a chrome.tabs onClick event

Is there any way to fire or simulate a click event on the currently-open Chrome tab using the chrome.tabs API? 有什么方法可以使用chrome.tabs API在当前打开的Chrome标签上触发或模拟点击事件?

Looking through chrome.tabs extension documentation , I'm finding events such as onHighlighted and onActivated , but they seem to deal with changing the current tab and/or window. 查看chrome.tabs扩展文档 ,我发现诸如onHighlightedonActivated事件,但它们似乎与更改当前选项卡和/或窗口有关。

I'm looking for a way to respond to clicking the current tab, such as using the following code: 我正在寻找一种方法来响应单击当前选项卡,例如使用以下代码:

chrome.tabs.onClicked.addListener(function (tabId, tab) { 
    alert("Clicked!");    
});

But sadly, this doesn't work. 但可悲的是,这行不通。 Are there any alternatives? 还有其他选择吗?

No, there isn't. 不,没有。 Clicking on the current tab doesn't do anything, and users wouldn't normally click there for any reason (unless of course they're about to click the X to close), so it wouldn't make sense to generate an event for that click. 单击当前选项卡不会执行任何操作,并且用户通常不会出于任何原因单击那里(除非他们当然要单击X来关闭),所以为该事件生成事件没有任何意义。点击。 Doing so would give potential meaning to an unclickable part of the browser chrome, which would be really confusing for users. 这样做会给浏览器镶边中不可点击的部分带来潜在的意义,这对用户来说确实很令人困惑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM