Chrome浏览器操作弹出窗口和图标开关不起作用 [英] Chrome Browser Action Popup and icon switch does not work

查看:216
本文介绍了Chrome浏览器操作弹出窗口和图标开关不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为我的Chrome扩展程序使用默认弹出窗口时,我无法更改扩展程序状态的图标。如果我禁用popup.html状态更改图标正在工作。我使用切换方法来更改图标,而不使用popup.html,这些图标完美无缺。
这怎么可能?任何人都可以帮助我吗?

While using a default popup for my Chrome extension, I can't change the icon for the state of the extension. If I disable the popup.html the state changing icons are working. I used a toggle method for changing the icons, which worked perfectly before without using the popup.html. How is that possible? Can anyone help me please?

在此先感谢!

推荐答案

如果您有弹出式菜单设置, chrome.browserAction.onClicked 未触发

When you have a popup set, chrome.browserAction.onClicked is not fired.

您需要在弹出窗口中通知您的扩展程序的后台页面,以通知它有关点击的信息,例如:

You will need to message your extension's background page from the popup to inform it about the click, e.g.:

// background script
chrome.runtime.onMessage.addListener( function (message, sender, sendResponse) {
  if (message.clicked) {
    /* Do the usual onClicked stuff */
  }
});

// popup script
chrome.runtime.sendMessage({clicked : true});

这篇关于Chrome浏览器操作弹出窗口和图标开关不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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