背景.html vs.背景.js - chrome扩展
background.html vs. background.js - chrome extension
我真的很困惑。我试图了解chrome扩展的文件架构。我正在阅读这个文档:https://developer.chrome.com/extensions/overview#arch
我的情况:
我想设置oauth流,以便用户可以在扩展内登录(另一个端点是我的django后端)。到目前为止,我有这些文件:
background.js
content.js
popup.html
manifest.json
where my content.js发送消息到后台并得到响应。到目前为止一切都很好!
但现在,而阅读文件为oauth,我很困惑不知道什么背景。html是。它实际上是应该包含我的背景。js的所有js代码的文件?但是,如果我在清单中将其更改为.html
,如:
"background": {
"persistent": false,
"scripts": ["jquery111.js", "background.html"]
扩展名不再工作。在OAuth文档中,它说:
Place the four library files in the root of your extension directory
(or wherever your JavaScript is stored). Then include the .js files in your
background page...
Your background page will manage the OAuth flow.
但是在架构文档中,它说:
This figure shows the browser action's background page, which is defined by
background.html and has JavaScript code that controls the behavior of
the browser action in both windows.
background.html和background.js有什么区别?
您只允许指定一个脚本数组…
"background": {
"persistent": false,
"scripts": [ "jquery111.js"]
}
…或一个页面,然后可以引用页面所需的脚本:
"background": {
"persistent": false,
"page": "background.html"
}
理论上,您的background.html
页面可以只是一个所需脚本的列表。
<script src="jquery111.js"></script>
如果你试图同时指定这两个选项,扩展将无法加载:
的背景。页面和背景。脚本属性不能同时使用。无法载入舱单。
相关文章:
- 从已经运行的进程打开chrome扩展的背景页
- 我的'body'css背景图像在chrome中跳跃
- Chrome:刷新页面后未呈现的背景图像 + JavaScript 重定向
- 是否可以使用chrome.tabs.sendmessage从内容脚本向背景页发送消息
- Chrome通过自动填充隐藏背景图像
- Chrome Mobile上的网站背景是崎岖不平的
- 视差背景修复了Chrome和Safari中的错误
- Chrome扩展程序 - 以编程方式打开/关闭背景页面
- 用于编辑谷歌背景颜色的Chrome扩展程序
- Chrome 扩展 WebSQL - 需要背景和内容页面才能访问相同的数据库,但它们不需要
- 如何动态更改背景.js以反映用户在 chrome 中的设置
- Chrome扩展程序:如何在新选项卡中显示背景图像
- 在弹出窗口,背景页面,Chrome扩展程序中访问w.location.href
- 如何通过扩展程序获取(未设置)Chrome中所选文本的背景颜色
- Chrome 扩展程序背景页错误:“未捕获的语法错误:意外的令牌<”
- Chrome 扩展 API:Chrome.tabs.captureVisibleTab 在背景页面上到内容脚本
- Chrome扩展以调暗背景
- fancyBox v2:如何防止Chrome中的背景滚动
- Chrome扩展:正确添加具有非持久背景页的上下文菜单项
- 在弹出窗口和背景Chrome扩展之间工作