Google Chrome扩展程序问题:popup.html干扰了background.html中的脚本执行 [英] Google chrome extension issue: popup.html interferes with script execution in background.html
本文介绍了Google Chrome扩展程序问题:popup.html干扰了background.html中的脚本执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习如何扩展Google chrome,但遇到了以下问题:
I am learning how to extend Google chrome and I have run into the following problem:
我有以下清单文件:
{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"background_page": "background.html",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
]
}
我的background.html文件只是将一些简单的JavaScript注入页面:
My background.html file just injects some simple JavaScript into the page:
<script>
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(null, {code:"alert(\"hi from background CODE\");"});
});
</script>
我的popup.html文件只是简单的HTML:
My popup.html file is just simple HTML:
<body>
Sup Playa
</body>
background.html对话框永远不会显示. popup.html可以正常运行.
The dialog box from background.html never gets displayed. popup.html functions as expected.
但是,当我从清单文件中注释掉popup.html时,background.html中的脚本可以工作.
However when I comment out popup.html from the manifest file, the script in background.html works.
我做错了什么?为什么没有同时显示对话框和弹出窗口?
What am I doing wrong? Why aren't both the dialog box and the popup showing up?
推荐答案
查看全文