javascript - 在 chrome 中创建新选项卡时,我想重定向到自定义 html 页面
问题描述
我正在开发一个 chrome 扩展。创建新选项卡时,我想重定向到自定义 html 页面。
这是 process.js 文件。
chrome.tabs.onCreated.addListener(function() {
alert("hello");
window.open('https://ucsc.cmb.ac.lk/', '_self', false);
});
这是 manifest.json 文件。
{
"manifest_version": 2,
"name": "xxx",
"version": "1.0",
"description": "xxx",
"icons": {
"128": "icon128.png",
"48": "icon48.png",
"16": "icon16.png"
},
"browser_action": {
"default_icon": "icon16.png",
"default_popup": "popup.html"
},
"background": {
"scripts": ["process.js"],
"presistent": true
},
"permissions": [
"storage",
"notifications",
"contextMenus",
"tabs",
"activeTab",
"http://*/",
"https://*/"
]
}
警报正在工作。但它没有加载页面。
解决方案
您可能正在寻找Override Pages。
将此代码添加到您的清单文件中:
"chrome_url_overrides" : {
"pageToOverride": "myPage.html"
},
推荐阅读
- google-cloud-ml - AI Platform 上所有日志的严重性为错误
- asp.net-mvc - 一对多或多对多关系
- python - 检查字典中的重复值
- python - 列表打印问题
- google-cloud-platform - 如何在 google cloud sql server 中启用 CDC 以进行 AWS DMS 复制?
- javascript - (Trello.js) 在函数中获得响应后返回 ID
- javascript - 如何优化 IndexedDb 性能?多个 indexeddb 与多个对象存储?
- javascript - 如何使用 Ammo.btCompoundShape(Bullet Physics 的 JavaScript 端口)?
- javascript - 如何在没有安装的情况下在 VueRouter 中解析 $route
? - r - 如何从 R 中的其他变量复制日期?