简体   繁体   中英

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?

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.

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. Doing so would give potential meaning to an unclickable part of the browser chrome, which would be really confusing for users.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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