简体   繁体   English

如何通过javascript重新加载chrome扩展程序?

[英]How can I reload my chrome extension by javascript?

I'm trying to make that if you press a button in the popup window in my chrome extension, it will reload the extension. 我试图让我在chrome扩展程序的弹出窗口中按一个按钮,它将重新加载该扩展程序。 Is that possible? 那可能吗?

刚刚找到此方法 ,它确实满足我的要求:

chrome.runtime.reload();

Add this code to manifest.json: 将此代码添加到manifest.json:

"background": {
  "persistent": false,
  "scripts": [ "background.js" ]
}

Add this code to background.js: 将此代码添加到background.js:

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.runtime.reload();
});

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

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